diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py index 198816835b24..8cf249eb2125 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._communication_identity_client import CommunicationIdentityClient +from ._communication_identity_client_async import CommunicationIdentityClient __all__ = ['CommunicationIdentityClient'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client_async.py similarity index 90% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client_async.py index 06c5aa66ddff..3b7eaf39cd0f 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client_async.py @@ -11,8 +11,8 @@ from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer -from ._configuration import CommunicationIdentityClientConfiguration -from .operations import CommunicationIdentityOperations +from ._configuration_async import CommunicationIdentityClientConfiguration +from .operations_async import CommunicationIdentityOperations from .. import models @@ -20,7 +20,7 @@ class CommunicationIdentityClient(object): """Azure Communication Identity Service. :ivar communication_identity: CommunicationIdentityOperations operations - :vartype communication_identity: azure.communication.administration.aio.operations.CommunicationIdentityOperations + :vartype communication_identity: azure.communication.administration.aio.operations_async.CommunicationIdentityOperations :param endpoint: Auth and Identity endpoint. :type endpoint: str """ diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration_async.py similarity index 100% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration_async.py diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/__init__.py similarity index 85% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/__init__.py index 09dd0f2d0661..d03c3e70894b 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/__init__.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._communication_identity_operations import CommunicationIdentityOperations +from ._communication_identity_operations_async import CommunicationIdentityOperations __all__ = [ 'CommunicationIdentityOperations', diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/_communication_identity_operations_async.py similarity index 92% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/_communication_identity_operations_async.py index 9ff3934e2458..ab5fc3752075 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations_async/_communication_identity_operations_async.py @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest @@ -54,12 +54,9 @@ async def create( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2020-07-20-preview2" - accept = "application/json" # Construct URL url = self.create.metadata['url'] # type: ignore @@ -74,7 +71,7 @@ async def create( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + header_parameters['Accept'] = 'application/json' request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -109,9 +106,7 @@ async def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2020-07-20-preview2" @@ -163,9 +158,7 @@ async def update( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) @@ -192,6 +185,7 @@ async def update( body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') 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 @@ -224,15 +218,12 @@ async def issue_token( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) _body = models.CommunicationTokenRequest(scopes=scopes) api_version = "2020-07-20-preview2" content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" # Construct URL url = self.issue_token.metadata['url'] # type: ignore @@ -249,12 +240,13 @@ async def issue_token( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + header_parameters['Accept'] = 'application/json' body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'CommunicationTokenRequest') 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 diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py index 26d1a86a88d2..22574cec81ca 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse @@ -59,12 +59,9 @@ def create( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2020-07-20-preview2" - accept = "application/json" # Construct URL url = self.create.metadata['url'] # type: ignore @@ -79,7 +76,7 @@ def create( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + header_parameters['Accept'] = 'application/json' request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -115,9 +112,7 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2020-07-20-preview2" @@ -170,9 +165,7 @@ def update( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) @@ -199,6 +192,7 @@ def update( body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') 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 @@ -232,15 +226,12 @@ def issue_token( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) _body = models.CommunicationTokenRequest(scopes=scopes) api_version = "2020-07-20-preview2" content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" # Construct URL url = self.issue_token.metadata['url'] # type: ignore @@ -257,12 +248,13 @@ def issue_token( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + header_parameters['Accept'] = 'application/json' body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'CommunicationTokenRequest') 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 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 f34a07d5b0e4..293035b169b3 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 @@ -4,33 +4,13 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -from azure.communication.administration._phonenumber._generated.models import ReleaseStatus, CreateSearchOptions from azure.core.tracing.decorator import distributed_trace from azure.core.paging import ItemPaged from azure.core.polling import LROPoller -from ._polling import ReleasePhoneNumberPolling, ReservePhoneNumberPolling, PurchaseReservationPolling from ._phonenumber._generated._phone_number_administration_service\ import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen -from ._phonenumber._generated.models import ( - AcquiredPhoneNumbers, - AreaCodes, - LocationOptionsResponse, - NumberConfigurationResponse, - NumberUpdateCapabilities, - PhoneNumberCountries, - PhoneNumberEntities, - PhoneNumberRelease, - PhoneNumberReservation, - PhonePlanGroups, - PhonePlansResponse, - PstnConfiguration, - SearchStatus, - UpdateNumberCapabilitiesResponse, - UpdatePhoneNumberCapabilitiesResponse -) - from ._shared.utils import parse_connection_str from ._shared.policy import HMACCredentialsPolicy from ._version import SDK_MONIKER @@ -51,22 +31,7 @@ def __init__( **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) + pass @classmethod def from_connection_string( @@ -80,520 +45,139 @@ def from_connection_string( :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 - ) + pass @distributed_trace - def get_capabilities_update( + def begin_search_phone_numbers( self, - capabilities_update_id, # type: str + country_code, #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( + # type: (str, Any) -> LROPoller[SearchResult] + """Begins creating a phone number search to reserve phone numbers. + :param str country_code: country code for the search + :keyword number_type: Required. The phone number type. Possible values include: "tollFree", + "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :keyword assignment_type: Required. The phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :keyword capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.SearchCapabilities + :keyword area_code: The desired area code. + :type area_code: str + :keyword quantity: The desired quantity of phone numbers. + :type quantity: int + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.SearchResult] + """ + pass + + @distributed_trace + def begin_purchase_phone_numbers( self, - pstn_configuration, # type: PstnConfiguration - phone_number, # type: str - **kwargs # type: Any + search_id, #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 + #type: (str, Any) -> LROPoller[SearchResult] + """Begins purchasing a phone number search + :param str search_id: Id for the search + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.SearchResult] """ - return self._phone_number_administration_client.phone_number_administration.configure_number( - pstn_configuration, - phone_number, - **kwargs - ) + pass @distributed_trace - def unconfigure_number( + def get_search_result( self, - phone_number, # type: str - **kwargs # type: Any + search_id, #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 + #type: (str, Any) -> SearchResult + """Gets the search associated with the id + :param str search_id: Id for the search + :returns: Search result associated with the search id + :rtype: ~azure.communication.administration.SearchResult """ - return self._phone_number_administration_client.phone_number_administration.unconfigure_number( - phone_number, - **kwargs - ) + pass @distributed_trace - def list_phone_plan_groups( + def get_operation( self, - country_code, # type: str - **kwargs # type: Any + operation_id, #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] + #type: (str, Any) -> Operation + """Gets the operation associated with the id + :param str operation_id: Id for the operation + :returns: Operation associated with the Id + :rtype: ~azure.communication.administration.Operation """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plan_groups( - country_code, - **kwargs - ) + pass @distributed_trace - def list_phone_plans( + def cancel_operation( self, - country_code, # type: str - phone_plan_group_id, # type: str - **kwargs # type: Any + operation_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] + #type: (str, Any) -> None + """Cancels the operation associated with the id + :param str operation_id: Id for the operation """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plans( - country_code, - phone_plan_group_id, - **kwargs - ) + pass @distributed_trace - def get_phone_plan_location_options( + def list_acquired_phone_numbers( self, - country_code, # type: str - phone_plan_group_id, # type: str - phone_plan_id, # type: str **kwargs # type: Any ): - # type: (...) -> LocationOptionsResponse - """Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.communication.administration.LocationOptionsResponse - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plan_location_options( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id, - phone_plan_id=phone_plan_id, - **kwargs - ) - - @distributed_trace - def get_release_by_id( - self, - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberRelease - """Gets a release by a release id. - - :param release_id: Represents the release id. - :type release_id: str - :rtype: ~azure.communication.administration.PhoneNumberRelease - """ - return self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id, - **kwargs - ) - - @distributed_trace - def begin_release_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> LROPoller[PhoneNumberRelease] - """Begins creating a release for the given phone numbers. - Caller must provide either phone_numbers, or continuation_token keywords to use the method. - If both phone_numbers and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword phone_numbers will be ignored. - - :keyword list[str] phone_numbers: The list of phone numbers in the release request. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberRelease] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - release_polling = ReleasePhoneNumberPolling( - is_terminated=lambda status: status in [ - ReleaseStatus.Complete, - ReleaseStatus.Failed, - ReleaseStatus.Expired - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=release_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "phone_numbers" not in kwargs: - raise ValueError("Either kwarg 'phone_numbers' or 'continuation_token' needs to be specified") - - create_release_response = self._phone_number_administration_client.\ - phone_number_administration.release_phone_numbers( - **kwargs - ) - - initial_state = self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id=create_release_response.release_id - ) - - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=release_polling) - - @distributed_trace - def list_all_releases( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhoneNumberEntities] - """Gets a list of all releases. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_releases( - **kwargs - ) - - @distributed_trace - def get_reservation_by_id( - self, - reservation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberReservation - """Get reservation by reservation id. - - :param reservation_id: The reservation id to get reservation. - :type reservation_id: str - :rtype: ~azure.communication.administration.PhoneNumberReservation + # type: (...) -> ItemPaged[AcquiredPhoneNumbers] + """Gets the list of the acquired phone numbers. + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.AcquiredPhoneNumbers] """ - return self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id, - **kwargs - ) + pass @distributed_trace - def begin_reserve_phone_numbers( + def get_phone_number( self, - **kwargs # type: Any + phone_number, #type: str + **kwargs # type: Any ): - # type: (...) -> LROPoller[PhoneNumberReservation] - """Begins creating a phone number search to reserve phone numbers. - Caller must provide one of the following: - (1) all of keywords display_name, description, phone_plan_ids, area_code, quantity if all the phone plans - to reserve are toll-free plans. - (2) all of keywords display_name, description, phone_plan_ids, area_code, quantity, location_options - if at least one phone plan to reserve is not toll-free plans. - (3) only keyword continuation_token to restart a poller from a saved state. - If both continuation_token and other keywords are specified, only continuation_token will be used to - restart a poller from a saved state, and other keywords will be ignored. - :keyword str display_name: display name of the search. - :keyword str description: description of the search. - :keyword list[str] phone_plan_ids: the plan subtype ids from which to create the search. - :keyword str area_code: the area code from which to create the search. - :keyword int quantity: the quantity of phone numbers to request. - :keyword list[~azure.communication.administration.models.LocationOptionsDetails] location_options: - the location options of the search. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberReservation] + #type: (str, Any) -> AcquiredPhoneNumber + """Gets the details of the phone number + :param str phone_number: The phone number to get details + :returns: The phone number details + :rtype: ~azure.communication.administration.AcquiredPhoneNumber """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = ReservePhoneNumberPolling( - is_terminated=lambda status: status in [ - SearchStatus.Reserved, - SearchStatus.Expired, - SearchStatus.Success, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - required_kwargs = ['display_name', 'description', 'phone_plan_ids', 'area_code', 'quantity'] - for required_kwarg in required_kwargs: - if required_kwarg not in kwargs: - raise ValueError("Either kwarg 'continuation_token', or a set of kwargs " + - "'display_name', 'description', 'phone_plan_ids', " - "'area_code', 'quantity' needs to be specified") - - reservation_options = CreateSearchOptions( - display_name=kwargs.pop('display_name'), - description=kwargs.pop('description'), - phone_plan_ids=kwargs.pop('phone_plan_ids'), - area_code=kwargs.pop('area_code'), - quantity=kwargs.pop('quantity') - ) - - if 'location_options' in kwargs: - reservation_options.location_options = kwargs.pop('location_options') - - create_reservation_response = self._phone_number_administration_client.\ - phone_number_administration.create_search( - body=reservation_options, - **kwargs - ) - - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=create_reservation_response.search_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) - - @distributed_trace - def list_all_reservations( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhoneNumberEntities] - """Gets a list of all reservations. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_searches( - **kwargs - ) + pass @distributed_trace - def cancel_reservation( + def begin_update_phone_number( self, - reservation_id, # type: str + phone_number, #type: str **kwargs # type: Any ): - # type: (...) -> None - """Cancels the reservation. This means existing numbers in the reservation will be made available. - - :param reservation_id: The reservation id to be canceled. - :type reservation_id: str - :rtype: None + # type: (str, Any) -> LROPoller[AcquiredPhoneNumber] + """Updates the phone number capabailities + :param str phone_number: The phone number to get details + :keyword callback_url: The webhook URL for receiving incoming events. + :type callback_url: str + :keyword application_id: The application id the number has been assigned to. + :type application_id: str + :keyword capabilities: The new set of enabled capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.SearchResult] """ - return self._phone_number_administration_client.phone_number_administration.cancel_search( - search_id=reservation_id, - **kwargs - ) + pass @distributed_trace - def begin_purchase_reservation( + def begin_release_phone_number( self, + phone_number, #type: str **kwargs # type: Any ): - # type: (...) -> LROPoller[PhoneNumberReservation] - """Begins purchase the reserved phone numbers of a phone number search. - Caller must provide either reservation_id, or continuation_token keywords to use the method. - If both reservation_id and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword reservation_id will be ignored. - :keyword str reservation_id: The reservation id to be purchased. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberReservation] + # type: (str, Any) -> LROPoller[None] + """Releases an already acquired phone number + :param str phone_number: The phone number to get details """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = PurchaseReservationPolling( - is_terminated=lambda status: status in [ - SearchStatus.Success, - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "reservation_id" not in kwargs: - raise ValueError("Either kwarg 'reservation_id' or 'continuation_token' needs to be specified") - - reservation_id = kwargs.pop('reservation_id') # type: str + pass - self._phone_number_administration_client.phone_number_administration.purchase_search( - search_id=reservation_id, - **kwargs - ) - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py index 13fcd7af35ce..d759d60d5d2f 100644 --- 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 @@ -6,8 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_service import PhoneNumberAdministrationService -__all__ = ['PhoneNumberAdministrationService'] +from ._phone_number_administration_client import PhoneNumberAdministrationClient +__all__ = ['PhoneNumberAdministrationClient'] try: from ._patch import patch_sdk # type: ignore 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 index 2043f061b4f2..29901a24be89 100644 --- 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 @@ -17,8 +17,8 @@ VERSION = "unknown" -class PhoneNumberAdministrationServiceConfiguration(Configuration): - """Configuration for PhoneNumberAdministrationService. +class PhoneNumberAdministrationClientConfiguration(Configuration): + """Configuration for PhoneNumberAdministrationClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -35,11 +35,11 @@ def __init__( # type: (...) -> None if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + super(PhoneNumberAdministrationClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint self.api_version = "2020-07-20-preview1" - kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'phonenumberadministrationclient/{}'.format(VERSION)) self._configure(**kwargs) def _configure( 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_client.py similarity index 79% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_service.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_client.py index 49830756eba4..4517d503009f 100644 --- 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_client.py @@ -15,18 +15,19 @@ # pylint: disable=unused-import,ungrouped-imports from typing import Any -from ._configuration import PhoneNumberAdministrationServiceConfiguration +from ._configuration import PhoneNumberAdministrationClientConfiguration from .operations import PhoneNumberAdministrationOperations from . import models -class PhoneNumberAdministrationService(object): - """Phone Number Administration Service. +class PhoneNumberAdministrationClient(object): + """The phone number administration client uses the Communication Services to acquire and manage phone numbers. :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( @@ -36,7 +37,7 @@ def __init__( ): # type: (...) -> None base_url = '{endpoint}' - self._config = PhoneNumberAdministrationServiceConfiguration(endpoint, **kwargs) + self._config = PhoneNumberAdministrationClientConfiguration(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)} @@ -51,7 +52,7 @@ def close(self): self._client.close() def __enter__(self): - # type: () -> PhoneNumberAdministrationService + # type: () -> PhoneNumberAdministrationClient self._client.__enter__() return self 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 index 6ec72fc665b1..983c41f477e5 100644 --- 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 @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_service_async import PhoneNumberAdministrationService -__all__ = ['PhoneNumberAdministrationService'] +from ._phone_number_administration_client_async import PhoneNumberAdministrationClient +__all__ = ['PhoneNumberAdministrationClient'] 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 index 7a46556ea91d..44528d00f6c4 100644 --- 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 @@ -13,8 +13,8 @@ VERSION = "unknown" -class PhoneNumberAdministrationServiceConfiguration(Configuration): - """Configuration for PhoneNumberAdministrationService. +class PhoneNumberAdministrationClientConfiguration(Configuration): + """Configuration for PhoneNumberAdministrationClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -30,11 +30,11 @@ def __init__( ) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + super(PhoneNumberAdministrationClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint self.api_version = "2020-07-20-preview1" - kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'phonenumberadministrationclient/{}'.format(VERSION)) self._configure(**kwargs) def _configure( 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_client_async.py similarity index 77% rename from sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_service_async.py rename to sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_client_async.py index 4c6d33b7c250..edf719682922 100644 --- 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_client_async.py @@ -11,18 +11,19 @@ from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer -from ._configuration_async import PhoneNumberAdministrationServiceConfiguration +from ._configuration_async import PhoneNumberAdministrationClientConfiguration from .operations_async import PhoneNumberAdministrationOperations from .. import models -class PhoneNumberAdministrationService(object): - """Phone Number Administration Service. +class PhoneNumberAdministrationClient(object): + """The phone number administration client uses the Communication Services to acquire and manage phone numbers. :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( @@ -31,7 +32,7 @@ def __init__( **kwargs: Any ) -> None: base_url = '{endpoint}' - self._config = PhoneNumberAdministrationServiceConfiguration(endpoint, **kwargs) + self._config = PhoneNumberAdministrationClientConfiguration(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)} @@ -44,7 +45,7 @@ def __init__( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "PhoneNumberAdministrationService": + async def __aenter__(self) -> "PhoneNumberAdministrationClient": await self._client.__aenter__() return self 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 d4b26cb33e88..4b20f7bd71f2 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 @@ -5,13 +5,15 @@ # 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 +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling from ... import models @@ -40,841 +42,163 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def get_all_phone_numbers( - self, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["models.AcquiredPhoneNumbers"]: - """Gets the list of the acquired phone numbers. - - Gets the list of the acquired phone numbers. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.models.AcquiredPhoneNumbers] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumbers"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_all_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) - list_of_elem = deserialized.phone_numbers - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_phone_numbers.metadata = {'url': '/administration/phonenumbers/phonenumbers'} # type: ignore - - async def get_all_area_codes( - self, - location_type: str, - country_code: str, - phone_plan_id: str, - location_options: Optional[List["models.LocationOptionsQuery"]] = None, - **kwargs - ) -> "models.AreaCodes": - """Gets a list of the supported area codes. - - Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.administration.models.LocationOptionsQuery] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AreaCodes, or the result of cls(response) - :rtype: ~azure.communication.administration.models.AreaCodes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AreaCodes"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.LocationOptionsQueries(location_options=location_options) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.get_all_area_codes.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['locationType'] = self._serialize.query("location_type", location_type, 'str') - query_parameters['phonePlanId'] = self._serialize.query("phone_plan_id", phone_plan_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'LocationOptionsQueries') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AreaCodes', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_all_area_codes.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/areacodes'} # type: ignore - - async def get_capabilities_update( - self, - capabilities_update_id: str, - **kwargs - ) -> "models.UpdatePhoneNumberCapabilitiesResponse": - """Get capabilities by capabilities update id. - - Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdatePhoneNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.UpdatePhoneNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.UpdatePhoneNumberCapabilitiesResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - # Construct URL - url = self.get_capabilities_update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'capabilitiesUpdateId': self._serialize.url("capabilities_update_id", capabilities_update_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdatePhoneNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_capabilities_update.metadata = {'url': '/administration/phonenumbers/capabilities/{capabilitiesUpdateId}'} # type: ignore - - async def update_capabilities( - self, - phone_number_capabilities_update: Dict[str, "models.NumberUpdateCapabilities"], - **kwargs - ) -> "models.UpdateNumberCapabilitiesResponse": - """Adds or removes phone number capabilities. - - Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: dict[str, ~azure.communication.administration.models.NumberUpdateCapabilities] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.UpdateNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.UpdateNumberCapabilitiesResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.UpdateNumberCapabilitiesRequest(phone_number_capabilities_update=phone_number_capabilities_update) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'UpdateNumberCapabilitiesRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_capabilities.metadata = {'url': '/administration/phonenumbers/capabilities'} # type: ignore - - def get_all_supported_countries( - self, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["models.PhoneNumberCountries"]: - """Gets a list of supported countries. - - Gets a list of supported countries. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberCountries or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.models.PhoneNumberCountries] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberCountries"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_all_supported_countries.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberCountries', pipeline_response) - list_of_elem = deserialized.countries - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_supported_countries.metadata = {'url': '/administration/phonenumbers/countries'} # type: ignore - - async def get_number_configuration( - self, - phone_number: str, - **kwargs - ) -> "models.NumberConfigurationResponse": - """Endpoint for getting number configurations. - - Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NumberConfigurationResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.NumberConfigurationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.NumberConfigurationResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.get_number_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('NumberConfigurationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_number_configuration.metadata = {'url': '/administration/phonenumbers/numberconfiguration'} # type: ignore - - async def configure_number( - self, - pstn_configuration: "models.PstnConfiguration", - phone_number: str, - **kwargs - ) -> None: - """Endpoint for configuring a pstn number. - - Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.models.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfiguration(pstn_configuration=pstn_configuration, phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.configure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfiguration') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - configure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/configure'} # type: ignore - - async def unconfigure_number( - self, - phone_number: str, - **kwargs - ) -> None: - """Endpoint for unconfiguring a pstn number by removing the configuration. - - Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.unconfigure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unconfigure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/unconfigure'} # type: ignore - - def get_phone_plan_groups( - self, - country_code: str, - locale: Optional[str] = "en-US", - include_rate_information: Optional[bool] = False, - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["models.PhonePlanGroups"]: - """Gets a list of phone plan groups for the given country. - - Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param include_rate_information: - :type include_rate_information: bool - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlanGroups or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.models.PhonePlanGroups] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlanGroups"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_phone_plan_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if include_rate_information is not None: - query_parameters['includeRateInformation'] = self._serialize.query("include_rate_information", include_rate_information, 'bool') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlanGroups', pipeline_response) - list_of_elem = deserialized.phone_plan_groups - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_phone_plan_groups.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups'} # type: ignore - - def get_phone_plans( - self, - country_code: str, - phone_plan_group_id: str, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["models.PhonePlansResponse"]: - """Gets a list of phone plans for a phone plan group. - - Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlansResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.models.PhonePlansResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlansResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_phone_plans.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlansResponse', pipeline_response) - list_of_elem = deserialized.phone_plans - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_phone_plans.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans'} # type: ignore - - async def get_phone_plan_location_options( + async def _search_available_phone_numbers_initial( self, country_code: str, - phone_plan_group_id: str, - phone_plan_id: str, - locale: Optional[str] = "en-US", + number_type: Union[str, "models.PhoneNumberType"], + assignment_type: Union[str, "models.AssignmentType"], + capabilities: "models.SearchCapabilities", + area_code: Optional[str] = None, + quantity: Optional[int] = 1, **kwargs - ) -> "models.LocationOptionsResponse": - """Gets a list of location options for a phone plan. - - Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationOptionsResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.LocationOptionsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationOptionsResponse"] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) + + _search = models.SearchRequest(number_type=number_type, assignment_type=assignment_type, capabilities=capabilities, area_code=area_code, quantity=quantity) api_version = "2020-07-20-preview1" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.get_phone_plan_location_options.metadata['url'] # type: ignore + url = self._search_available_phone_numbers_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'countryCode': self._serialize.url("country_code", country_code, 'str'), - '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' + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_search, 'SearchRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - 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]: + 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) - deserialized = self._deserialize('LocationOptionsResponse', pipeline_response) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - get_phone_plan_location_options.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions'} # type: ignore + _search_available_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/~search'} # type: ignore + + async def begin_search_available_phone_numbers( + self, + country_code: str, + number_type: Union[str, "models.PhoneNumberType"], + assignment_type: Union[str, "models.AssignmentType"], + capabilities: "models.SearchCapabilities", + area_code: Optional[str] = None, + quantity: Optional[int] = 1, + **kwargs + ) -> AsyncLROPoller[None]: + """Search for available phone numbers to purchase. + + Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code. + :type country_code: str + :param number_type: The phone number type. + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: The phone number's assignment type. + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.SearchCapabilities + :param area_code: The desired area code. + :type area_code: str + :param quantity: The desired quantity of phone numbers. + :type quantity: int + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._search_available_phone_numbers_initial( + country_code=country_code, + number_type=number_type, + assignment_type=assignment_type, + capabilities=capabilities, + area_code=area_code, + quantity=quantity, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_search_available_phone_numbers.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/~search'} # type: ignore - async def get_release_by_id( + async def get_search_result( self, - release_id: str, + search_id: str, **kwargs - ) -> "models.PhoneNumberRelease": - """Gets a release by a release id. + ) -> "models.SearchResult": + """Get a search result by its id. - Gets a release by a release id. + Get a search result by its id. - :param release_id: Represents the release id. - :type release_id: str + :param search_id: The search Id. + :type search_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberRelease, or the result of cls(response) - :rtype: ~azure.communication.administration.models.PhoneNumberRelease + :return: SearchResult, or the result of cls(response) + :rtype: ~azure.communication.administration.models.SearchResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberRelease"] + cls = kwargs.pop('cls', None) # type: ClsType["models.SearchResult"] 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 + url = self.get_search_result.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'releaseId': self._serialize.url("release_id", release_id, 'str'), + 'searchId': self._serialize.url("search_id", search_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -895,40 +219,29 @@ async def get_release_by_id( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('PhoneNumberRelease', pipeline_response) + deserialized = self._deserialize('SearchResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_release_by_id.metadata = {'url': '/administration/phonenumbers/releases/{releaseId}'} # type: ignore + get_search_result.metadata = {'url': '/availablePhoneNumbers/searchResults/{searchId}'} # type: ignore - async def release_phone_numbers( + async def _purchase_phone_numbers_initial( self, - phone_numbers: List[str], + search_id: Optional[str] = None, **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"] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - _body = models.ReleaseRequest(phone_numbers=phone_numbers) + _purchase = models.PurchaseRequest(search_id=search_id) 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 + url = self._purchase_phone_numbers_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -941,138 +254,110 @@ async def release_phone_numbers( # 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 = self._serialize.body(_purchase, 'PurchaseRequest') 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]: + 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) - deserialized = self._deserialize('ReleaseResponse', pipeline_response) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - release_phone_numbers.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore + _purchase_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/~purchase'} # type: ignore - def get_all_releases( + async def begin_purchase_phone_numbers( self, - skip: Optional[int] = 0, - take: Optional[int] = 100, + search_id: Optional[str] = None, **kwargs - ) -> AsyncIterable["models.PhoneNumberEntities"]: - """Gets a list of all releases. + ) -> AsyncLROPoller[None]: + """Purchase phone numbers. - Gets a list of all releases. + Purchase phone numbers. - :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 + :param search_id: The id of the search result to purchase. + :type search_id: str :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - 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 + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - get_all_releases.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._purchase_phone_numbers_initial( + search_id=search_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase_phone_numbers.metadata = {'url': '/availablePhoneNumbers/~purchase'} # type: ignore - async def get_search_by_id( + async def get_operation( self, - search_id: str, + operation_id: str, **kwargs - ) -> "models.PhoneNumberReservation": - """Get search by search id. + ) -> "models.Operation": + """Get an operation by its id. - Get search by search id. + Get an operation by its id. - :param search_id: The search id to be searched for. - :type search_id: str + :param operation_id: The operation Id. + :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberReservation, or the result of cls(response) - :rtype: ~azure.communication.administration.models.PhoneNumberReservation + :return: Operation, or the result of cls(response) + :rtype: ~azure.communication.administration.models.Operation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberReservation"] + cls = kwargs.pop('cls', None) # type: ClsType["models.Operation"] 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 + url = self.get_operation.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1093,40 +378,40 @@ async def get_search_by_id( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('PhoneNumberReservation', pipeline_response) + deserialized = self._deserialize('Operation', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_search_by_id.metadata = {'url': '/administration/phonenumbers/searches/{searchId}'} # type: ignore + get_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore - async def create_search( + async def cancel_operation( self, - body: Optional["models.CreateSearchOptions"] = None, + operation_id: str, **kwargs - ) -> "models.CreateSearchResponse": - """Creates a phone number search. + ) -> None: + """Cancels the operation if cancellation is supported for the operation type. - Creates a phone number search. + Cancels the operation if cancellation is supported for the operation type. - :param body: Defines the search options. - :type body: ~azure.communication.administration.models.CreateSearchOptions + :param operation_id: The operation Id. + :type operation_id: str :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 + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CreateSearchResponse"] + 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" - content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_search.metadata['url'] # type: ignore + url = self.cancel_operation.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1136,53 +421,35 @@ async def create_search( # 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) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [201]: + 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('CreateSearchResponse', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - create_search.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore + cancel_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore - def get_all_searches( + def list_phone_numbers( self, - skip: Optional[int] = 0, - take: Optional[int] = 100, **kwargs - ) -> AsyncIterable["models.PhoneNumberEntities"]: - """Gets a list of all searches. + ) -> AsyncIterable["models.AcquiredPhoneNumbers"]: + """Lists acquired phone numbers. - Gets a list of all searches. + Lists acquired phone numbers. - :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] + :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.PhoneNumberEntities"] + 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" @@ -1194,17 +461,13 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.get_all_searches.metadata['url'] # type: ignore + url = self.list_phone_numbers.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if 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) @@ -1219,8 +482,8 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities + deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) + list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, AsyncList(list_of_elem) @@ -1241,34 +504,84 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - get_all_searches.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore + list_phone_numbers.metadata = {'url': '/phoneNumbers'} # type: ignore - async def cancel_search( + async def get_phone_number( self, - search_id: str, + phone_number: str, **kwargs - ) -> None: - """Cancels the search. This means existing numbers in the search will be made available. + ) -> "models.AcquiredPhoneNumber": + """Gets information about an acquired phone number. - Cancels the search. This means existing numbers in the search will be made available. + Gets information about an acquired phone number. - :param search_id: The search id to be canceled. - :type search_id: str + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :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 + :return: AcquiredPhoneNumber, or the result of cls(response) + :rtype: ~azure.communication.administration.models.AcquiredPhoneNumber :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] 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 + url = self.get_phone_number.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'), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = '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('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + async def _update_phone_number_initial( + self, + phone_number: str, + callback_url: Optional[str] = None, + application_id: Optional[str] = None, + capabilities: Optional["models.Capabilities"] = None, + **kwargs + ) -> "models.AcquiredPhoneNumber": + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _update = models.AcquiredPhoneNumberUpdate(callback_url=callback_url, application_id=application_id, capabilities=capabilities) + api_version = "2020-07-20-preview1" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + + # Construct URL + url = self._update_phone_number_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1278,8 +591,14 @@ async def cancel_search( # 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] + body_content = self._serialize.body(_update, 'AcquiredPhoneNumberUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - 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 @@ -1288,37 +607,106 @@ async def cancel_search( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) - cancel_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/cancel'} # type: ignore + return deserialized + _update_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore - async def purchase_search( + async def begin_update_phone_number( self, - search_id: str, + phone_number: str, + callback_url: Optional[str] = None, + application_id: Optional[str] = None, + capabilities: Optional["models.Capabilities"] = None, **kwargs - ) -> None: - """Purchases the phone number search. + ) -> AsyncLROPoller["models.AcquiredPhoneNumber"]: + """Update an acquired phone number. - Purchases the phone number search. + Update an acquired phone number. - :param search_id: The search id to be purchased. - :type search_id: str + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :type phone_number: str + :param callback_url: The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: The application id the number has been assigned to. + :type application_id: str + :param capabilities: The new set of enabled capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AcquiredPhoneNumber or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.models.AcquiredPhoneNumber] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_phone_number_initial( + phone_number=phone_number, + callback_url=callback_url, + application_id=application_id, + capabilities=capabilities, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + async def _release_phone_number_initial( + self, + phone_number: str, + **kwargs + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {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 + url = self._release_phone_number_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1329,7 +717,7 @@ async def purchase_search( # Construct headers header_parameters = {} # type: Dict[str, Any] - request = self._client.post(url, query_parameters, header_parameters) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1338,7 +726,67 @@ async def purchase_search( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) + + _release_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + async def begin_release_phone_number( + self, + phone_number: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Releases an acquired phone number. - purchase_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/purchase'} # type: ignore + Releases an acquired phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :type phone_number: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._release_phone_number_initial( + phone_number=phone_number, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_release_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore 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 index 0548f7b51a32..8ea5577a8140 100644 --- 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 @@ -8,134 +8,55 @@ try: from ._models_py3 import AcquiredPhoneNumber + from ._models_py3 import AcquiredPhoneNumberUpdate 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 Capabilities + from ._models_py3 import Error from ._models_py3 import ErrorResponse - from ._models_py3 import LocationOptions - from ._models_py3 import LocationOptionsDetails - from ._models_py3 import LocationOptionsQueries - from ._models_py3 import LocationOptionsQuery - from ._models_py3 import LocationOptionsResponse - from ._models_py3 import NumberConfiguration - from ._models_py3 import NumberConfigurationPhoneNumber - from ._models_py3 import NumberConfigurationResponse - from ._models_py3 import NumberUpdateCapabilities - from ._models_py3 import PhoneNumberCountries - from ._models_py3 import PhoneNumberCountry - from ._models_py3 import PhoneNumberEntities - from ._models_py3 import PhoneNumberEntity - from ._models_py3 import PhoneNumberRelease - from ._models_py3 import PhoneNumberReleaseDetails - from ._models_py3 import PhoneNumberReservation - from ._models_py3 import PhonePlan - from ._models_py3 import PhonePlanGroup - from ._models_py3 import PhonePlanGroups - from ._models_py3 import PhonePlansResponse - from ._models_py3 import PstnConfiguration - from ._models_py3 import RateInformation - from ._models_py3 import ReleaseRequest - from ._models_py3 import ReleaseResponse - from ._models_py3 import UpdateNumberCapabilitiesRequest - from ._models_py3 import UpdateNumberCapabilitiesResponse - from ._models_py3 import UpdatePhoneNumberCapabilitiesResponse + from ._models_py3 import MonthlyRate + from ._models_py3 import Operation + from ._models_py3 import PurchaseRequest + from ._models_py3 import SearchCapabilities + from ._models_py3 import SearchRequest + from ._models_py3 import SearchResult except (SyntaxError, ImportError): from ._models import AcquiredPhoneNumber # type: ignore + from ._models import AcquiredPhoneNumberUpdate # 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 Capabilities # type: ignore + from ._models import Error # type: ignore from ._models import ErrorResponse # type: ignore - from ._models import LocationOptions # type: ignore - from ._models import LocationOptionsDetails # type: ignore - from ._models import LocationOptionsQueries # type: ignore - from ._models import LocationOptionsQuery # type: ignore - from ._models import LocationOptionsResponse # type: ignore - from ._models import NumberConfiguration # type: ignore - from ._models import NumberConfigurationPhoneNumber # type: ignore - from ._models import NumberConfigurationResponse # type: ignore - from ._models import NumberUpdateCapabilities # type: ignore - from ._models import PhoneNumberCountries # type: ignore - from ._models import PhoneNumberCountry # type: ignore - from ._models import PhoneNumberEntities # type: ignore - from ._models import PhoneNumberEntity # type: ignore - from ._models import PhoneNumberRelease # type: ignore - from ._models import PhoneNumberReleaseDetails # type: ignore - from ._models import PhoneNumberReservation # type: ignore - from ._models import PhonePlan # type: ignore - from ._models import PhonePlanGroup # type: ignore - from ._models import PhonePlanGroups # type: ignore - from ._models import PhonePlansResponse # type: ignore - from ._models import PstnConfiguration # type: ignore - from ._models import RateInformation # type: ignore - from ._models import ReleaseRequest # type: ignore - from ._models import ReleaseResponse # type: ignore - from ._models import UpdateNumberCapabilitiesRequest # type: ignore - from ._models import UpdateNumberCapabilitiesResponse # type: ignore - from ._models import UpdatePhoneNumberCapabilitiesResponse # type: ignore + from ._models import MonthlyRate # type: ignore + from ._models import Operation # type: ignore + from ._models import PurchaseRequest # type: ignore + from ._models import SearchCapabilities # type: ignore + from ._models import SearchRequest # type: ignore + from ._models import SearchResult # type: ignore -from ._phone_number_administration_service_enums import ( - ActivationState, - AssignmentStatus, - CapabilitiesUpdateStatus, - Capability, - CurrencyType, - LocationType, - PhoneNumberReleaseStatus, +from ._phone_number_administration_client_enums import ( + AssignmentType, + CapabilityValue, + OperationKind, + OperationStatusCodes, PhoneNumberType, - ReleaseStatus, - SearchStatus, ) __all__ = [ 'AcquiredPhoneNumber', + 'AcquiredPhoneNumberUpdate', 'AcquiredPhoneNumbers', - 'AreaCodes', - 'CarrierDetails', - 'CreateSearchOptions', - 'CreateSearchResponse', - 'ErrorBody', + 'Capabilities', + 'Error', 'ErrorResponse', - 'LocationOptions', - 'LocationOptionsDetails', - 'LocationOptionsQueries', - 'LocationOptionsQuery', - 'LocationOptionsResponse', - 'NumberConfiguration', - 'NumberConfigurationPhoneNumber', - 'NumberConfigurationResponse', - 'NumberUpdateCapabilities', - 'PhoneNumberCountries', - 'PhoneNumberCountry', - 'PhoneNumberEntities', - 'PhoneNumberEntity', - 'PhoneNumberRelease', - 'PhoneNumberReleaseDetails', - 'PhoneNumberReservation', - 'PhonePlan', - 'PhonePlanGroup', - 'PhonePlanGroups', - 'PhonePlansResponse', - 'PstnConfiguration', - 'RateInformation', - 'ReleaseRequest', - 'ReleaseResponse', - 'UpdateNumberCapabilitiesRequest', - 'UpdateNumberCapabilitiesResponse', - 'UpdatePhoneNumberCapabilitiesResponse', - 'ActivationState', - 'AssignmentStatus', - 'CapabilitiesUpdateStatus', - 'Capability', - 'CurrencyType', - 'LocationType', - 'PhoneNumberReleaseStatus', + 'MonthlyRate', + 'Operation', + 'PurchaseRequest', + 'SearchCapabilities', + 'SearchRequest', + 'SearchResult', + 'AssignmentType', + 'CapabilityValue', + 'OperationKind', + 'OperationStatusCodes', '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 index 6475102cafe9..db1b8bc6d2c1 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 @@ -11,44 +11,59 @@ class AcquiredPhoneNumber(msrest.serialization.Model): - """Represents an acquired phone number. + """The acquired phone number and its metadata and configuration. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. String of the E.164 format of the phone number. + :param id: Required. The id, this is the same as the phone number in E.164 format. + :type id: str + :param phone_number: Required. The phoneNumber in E.164 format. :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 + :param country_code: Required. The ISO 3166-2 country code of the country that the phone number + belongs to. + :type country_code: str + :param number_type: Required. The type of the phone number. Possible values include: + "tollFree", "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The assignment type of the phone number, people or + application. Possible values include: "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param purchase_date: Required. The purchase date of the phone number. + :type purchase_date: ~datetime.datetime + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities + :param callback_url: Required. The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: Required. The application id the number has been assigned to. + :type application_id: str + :param monthly_rate: Required. The monthly cost of the phone number. + :type monthly_rate: ~azure.communication.administration.models.MonthlyRate """ _validation = { + 'id': {'required': True}, 'phone_number': {'required': True}, - 'acquired_capabilities': {'required': True}, - 'available_capabilities': {'required': True}, + 'country_code': {'required': True}, + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'purchase_date': {'required': True}, + 'capabilities': {'required': True}, + 'callback_url': {'required': True}, + 'application_id': {'required': True}, + 'monthly_rate': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'acquired_capabilities': {'key': 'acquiredCapabilities', 'type': '[str]'}, - 'available_capabilities': {'key': 'availableCapabilities', 'type': '[str]'}, - 'assignment_status': {'key': 'assignmentStatus', 'type': 'str'}, - 'place_name': {'key': 'placeName', 'type': 'str'}, - 'activation_state': {'key': 'activationState', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'purchase_date': {'key': 'purchaseDate', 'type': 'iso-8601'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'monthly_rate': {'key': 'monthlyRate', 'type': 'MonthlyRate'}, } def __init__( @@ -56,51 +71,35 @@ def __init__( **kwargs ): super(AcquiredPhoneNumber, self).__init__(**kwargs) + self.id = kwargs['id'] self.phone_number = kwargs['phone_number'] - self.acquired_capabilities = kwargs['acquired_capabilities'] - self.available_capabilities = kwargs['available_capabilities'] - self.assignment_status = kwargs.get('assignment_status', None) - self.place_name = kwargs.get('place_name', None) - self.activation_state = kwargs.get('activation_state', None) + self.country_code = kwargs['country_code'] + self.number_type = kwargs['number_type'] + self.assignment_type = kwargs['assignment_type'] + self.purchase_date = kwargs['purchase_date'] + self.capabilities = kwargs['capabilities'] + self.callback_url = kwargs['callback_url'] + self.application_id = kwargs['application_id'] + self.monthly_rate = kwargs['monthly_rate'] class AcquiredPhoneNumbers(msrest.serialization.Model): - """A wrapper of list of phone numbers. + """The list of acquired phone numbers. - :param phone_numbers: Represents a list of phone numbers. - :type phone_numbers: list[~azure.communication.administration.models.AcquiredPhoneNumber] + All required parameters must be populated in order to send to Azure. + + :param value: Required. Represents a list of acquired phone numbers. + :type value: 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'}, + _validation = { + 'value': {'required': True}, } - def __init__( - self, - **kwargs - ): - super(AcquiredPhoneNumbers, self).__init__(**kwargs) - self.phone_numbers = kwargs.get('phone_numbers', None) - self.next_link = kwargs.get('next_link', None) - - -class AreaCodes(msrest.serialization.Model): - """Represents a list of area codes. - - :param primary_area_codes: Represents the list of primary area codes. - :type primary_area_codes: list[str] - :param secondary_area_codes: Represents the list of secondary area codes. - :type secondary_area_codes: list[str] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - _attribute_map = { - 'primary_area_codes': {'key': 'primaryAreaCodes', 'type': '[str]'}, - 'secondary_area_codes': {'key': 'secondaryAreaCodes', 'type': '[str]'}, + 'value': {'key': 'value', 'type': '[AcquiredPhoneNumber]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } @@ -108,950 +107,360 @@ def __init__( self, **kwargs ): - super(AreaCodes, self).__init__(**kwargs) - self.primary_area_codes = kwargs.get('primary_area_codes', None) - self.secondary_area_codes = kwargs.get('secondary_area_codes', None) + super(AcquiredPhoneNumbers, self).__init__(**kwargs) + self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) -class CarrierDetails(msrest.serialization.Model): - """Represents carrier details. +class AcquiredPhoneNumberUpdate(msrest.serialization.Model): + """The properties of a phone number that can be changed. - :param name: Name of carrier details. - :type name: str - :param localized_name: Display name of carrier details. - :type localized_name: str + :param callback_url: The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: The application id the number has been assigned to. + :type application_id: str + :param capabilities: The new set of enabled capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, } def __init__( self, **kwargs ): - super(CarrierDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.localized_name = kwargs.get('localized_name', None) + super(AcquiredPhoneNumberUpdate, self).__init__(**kwargs) + self.callback_url = kwargs.get('callback_url', None) + self.application_id = kwargs.get('application_id', None) + self.capabilities = kwargs.get('capabilities', None) -class CreateSearchOptions(msrest.serialization.Model): - """Represents a search creation option. +class Capabilities(msrest.serialization.Model): + """The capabilities of a phone number. 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] + :param sms: Required. Available Sms capabilities. Possible values include: "inbound", + "outbound", "inbound+outbound", "none". Default value: "none". + :type sms: str or ~azure.communication.administration.models.CapabilityValue + :param calling: Required. Available Calling capabilities. Possible values include: "inbound", + "outbound", "inbound+outbound", "none". Default value: "none". + :type calling: str or ~azure.communication.administration.models.CapabilityValue """ _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}, + 'sms': {'required': True}, + 'calling': {'required': True}, } _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]'}, + 'sms': {'key': 'sms', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, } 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) + super(Capabilities, self).__init__(**kwargs) + self.sms = kwargs.get('sms', "none") + self.calling = kwargs.get('calling', "none") -class CreateSearchResponse(msrest.serialization.Model): - """Represents a search creation response. +class Error(msrest.serialization.Model): + """Represents a service error response body. + + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param search_id: Required. The search id of the search that was created. - :type search_id: str + :param code: Required. The error code in the error response. + :type code: str + :param message: Required. The error message in the error response. + :type message: str + :ivar inner_error: Represents a service error response body. + :vartype inner_error: ~azure.communication.administration.models.Error """ _validation = { - 'search_id': {'required': True}, + 'code': {'required': True}, + 'message': {'required': True}, + 'inner_error': {'readonly': 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'}, + 'inner_error': {'key': 'innererror', 'type': 'Error'}, } def __init__( self, **kwargs ): - super(ErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) + super(Error, self).__init__(**kwargs) + self.code = kwargs['code'] + self.message = kwargs['message'] + self.inner_error = None class ErrorResponse(msrest.serialization.Model): """Represents a service error response. - :param error: Represents a service error response body. - :type error: ~azure.communication.administration.models.ErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorBody'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class LocationOptions(msrest.serialization.Model): - """Represents a location options. - - :param label_id: The label id of the location. - :type label_id: str - :param label_name: The display name of the location. - :type label_name: str - :param options: The underlying location option details. - :type options: list[~azure.communication.administration.models.LocationOptionsDetails] - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'label_name': {'key': 'labelName', 'type': 'str'}, - 'options': {'key': 'options', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptions, self).__init__(**kwargs) - self.label_id = kwargs.get('label_id', None) - self.label_name = kwargs.get('label_name', None) - self.options = kwargs.get('options', None) - - -class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options details. - - :param name: The name of the location options. - :type name: str - :param value: The abbreviated name of the location options. - :type value: str - :param location_options: The underlying location options. - :type location_options: list[~azure.communication.administration.models.LocationOptions] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptions]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - self.location_options = kwargs.get('location_options', None) - - -class LocationOptionsQueries(msrest.serialization.Model): - """Represents a list of location option queries, used for fetching area codes. - - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.administration.models.LocationOptionsQuery] - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsQuery]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsQueries, self).__init__(**kwargs) - self.location_options = kwargs.get('location_options', None) - - -class LocationOptionsQuery(msrest.serialization.Model): - """Represents a location options parameter, used for fetching area codes. - - :param label_id: Represents the location option label id, returned from the GetLocationOptions - API. - :type label_id: str - :param options_value: Represents the location options value, returned from the - GetLocationOptions API. - :type options_value: str - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'options_value': {'key': 'optionsValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsQuery, self).__init__(**kwargs) - self.label_id = kwargs.get('label_id', None) - self.options_value = kwargs.get('options_value', None) - - -class LocationOptionsResponse(msrest.serialization.Model): - """Represents a wrapper around a list of location options. - - :param location_options: Represents a location options. - :type location_options: ~azure.communication.administration.models.LocationOptions - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': 'LocationOptions'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsResponse, self).__init__(**kwargs) - self.location_options = kwargs.get('location_options', None) - - -class NumberConfiguration(msrest.serialization.Model): - """Definition for number configuration. - All required parameters must be populated in order to send to Azure. - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.models.PstnConfiguration - :param phone_number: Required. The phone number to configure. - :type phone_number: str + :param error: Required. Represents a service error response body. + :type error: ~azure.communication.administration.models.Error """ _validation = { - 'pstn_configuration': {'required': True}, - 'phone_number': {'required': True}, + 'error': {'required': True}, } _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, } def __init__( self, **kwargs ): - super(NumberConfiguration, self).__init__(**kwargs) - self.pstn_configuration = kwargs['pstn_configuration'] - self.phone_number = kwargs['phone_number'] + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs['error'] -class NumberConfigurationPhoneNumber(msrest.serialization.Model): - """The phone number wrapper representing a number configuration request. +class MonthlyRate(msrest.serialization.Model): + """The monthly incurred cost for a single phone number. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. The phone number in the E.164 format. - :type phone_number: str + :param value: Required. The cost amount. + :type value: float + :param currency: Required. The currency of the cost amount. + :type currency: str """ _validation = { - 'phone_number': {'required': True}, + 'value': {'required': True}, + 'currency': {'required': True}, } _attribute_map = { - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'currency': {'key': 'currency', 'type': 'str'}, } def __init__( self, **kwargs ): - super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) - self.phone_number = kwargs['phone_number'] + super(MonthlyRate, self).__init__(**kwargs) + self.value = kwargs['value'] + self.currency = kwargs['currency'] -class NumberConfigurationResponse(msrest.serialization.Model): - """Definition for number configuration. +class Operation(msrest.serialization.Model): + """Long running operation. 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 status: Required. Status of operation. Possible values include: "notStarted", "running", + "succeeded", "failed". + :type status: str or ~azure.communication.administration.models.OperationStatusCodes + :param id: Required. Id of the operation. + :type id: str + :param kind: Required. Kind of the operation. Possible values include: "search", "purchase", + "releasePhoneNumber", "updatePhoneNumber". + :type kind: str or ~azure.communication.administration.models.OperationKind + :param created_date_time: Required. The date that the operation was created. + :type created_date_time: ~datetime.datetime + :param last_action_date_time: Required. The most recent date that the operation was changed. + :type last_action_date_time: ~datetime.datetime + :param resource_location: Url for retrieving the result of the operation if any. + :type resource_location: str + :param error: Represents a service error response body. + :type error: ~azure.communication.administration.models.Error """ _validation = { - 'pstn_configuration': {'required': True}, + 'status': {'required': True}, + 'id': {'required': True}, + 'kind': {'required': True}, + 'created_date_time': {'required': True}, + 'last_action_date_time': {'required': True}, } _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + 'status': {'key': 'status', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, } def __init__( self, **kwargs ): - super(NumberConfigurationResponse, self).__init__(**kwargs) - self.pstn_configuration = kwargs['pstn_configuration'] + super(Operation, self).__init__(**kwargs) + self.status = kwargs['status'] + self.id = kwargs['id'] + self.kind = kwargs['kind'] + self.created_date_time = kwargs['created_date_time'] + self.last_action_date_time = kwargs['last_action_date_time'] + self.resource_location = kwargs.get('resource_location', None) + self.error = kwargs.get('error', None) -class NumberUpdateCapabilities(msrest.serialization.Model): - """Represents an individual number capabilities update request. +class PurchaseRequest(msrest.serialization.Model): + """Request to purchase phone numbers. - :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] + :param search_id: The id of the search result to purchase. + :type search_id: str """ _attribute_map = { - 'add': {'key': 'add', 'type': '[str]'}, - 'remove': {'key': 'remove', 'type': '[str]'}, + 'search_id': {'key': 'searchId', 'type': 'str'}, } def __init__( self, **kwargs ): - super(NumberUpdateCapabilities, self).__init__(**kwargs) - self.add = kwargs.get('add', None) - self.remove = kwargs.get('remove', None) + super(PurchaseRequest, self).__init__(**kwargs) + self.search_id = kwargs.get('search_id', None) -class PhoneNumberCountries(msrest.serialization.Model): - """Represents a wrapper around a list of countries. +class SearchCapabilities(msrest.serialization.Model): + """The capabilities of a phone number. - :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 + :param sms: Available Sms capabilities. Possible values include: "inbound", "outbound", + "inbound+outbound", "none". Default value: "none". + :type sms: str or ~azure.communication.administration.models.CapabilityValue + :param calling: Available Calling capabilities. Possible values include: "inbound", "outbound", + "inbound+outbound", "none". Default value: "none". + :type calling: str or ~azure.communication.administration.models.CapabilityValue """ _attribute_map = { - 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, } def __init__( self, **kwargs ): - super(PhoneNumberCountries, self).__init__(**kwargs) - self.countries = kwargs.get('countries', None) - self.next_link = kwargs.get('next_link', None) + super(SearchCapabilities, self).__init__(**kwargs) + self.sms = kwargs.get('sms', "none") + self.calling = kwargs.get('calling', "none") -class PhoneNumberCountry(msrest.serialization.Model): - """Represents a country. +class SearchRequest(msrest.serialization.Model): + """The desired properties of a phone number for search. All required parameters must be populated in order to send to Azure. - :param localized_name: Required. Represents the name of the country. - :type localized_name: str - :param country_code: Required. Represents the abbreviated name of the country. - :type country_code: str - """ - - _validation = { - 'localized_name': {'required': True}, - 'country_code': {'required': True}, - } - - _attribute_map = { - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PhoneNumberCountry, self).__init__(**kwargs) - self.localized_name = kwargs['localized_name'] - self.country_code = kwargs['country_code'] - - -class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searches or releases, as part of the response when fetching all searches or releases. - - :param entities: The underlying list of entities. - :type entities: list[~azure.communication.administration.models.PhoneNumberEntity] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'entities': {'key': 'entities', 'type': '[PhoneNumberEntity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PhoneNumberEntities, self).__init__(**kwargs) - self.entities = kwargs.get('entities', None) - self.next_link = kwargs.get('next_link', None) - - -class PhoneNumberEntity(msrest.serialization.Model): - """Represents a phone number entity, as part of the response when calling get all searches or releases. - - :param id: The id of the entity. It is the search id of a search. It is the release id of a - release. - :type id: str - :param created_at: Date and time the entity is created. - :type created_at: ~datetime.datetime - :param display_name: Name of the entity. - :type display_name: str - :param quantity: Quantity of requested phone numbers in the entity. + :param number_type: Required. The phone number type. Possible values include: "tollFree", + "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.SearchCapabilities + :param area_code: The desired area code. + :type area_code: str + :param quantity: The desired quantity of phone numbers. :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'}, + _validation = { + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, } - def __init__( - self, - **kwargs - ): - super(PhoneNumberReleaseDetails, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.error_code = kwargs.get('error_code', None) - - -class PhoneNumberReservation(msrest.serialization.Model): - """Represents a phone number search. - - :param reservation_id: The id of the search. - :type reservation_id: str - :param display_name: The name of the search. - :type display_name: str - :param created_at: The creation time of the search. - :type created_at: ~datetime.datetime - :param description: The description of the search. - :type description: str - :param phone_plan_ids: The phone plan ids of the search. - :type phone_plan_ids: list[str] - :param area_code: The area code of the search. - :type area_code: str - :param quantity: The quantity of phone numbers in the search. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.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 = { - 'reservation_id': {'key': 'searchId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'SearchCapabilities'}, '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(PhoneNumberReservation, self).__init__(**kwargs) - self.reservation_id = kwargs.get('reservation_id', None) - self.display_name = kwargs.get('display_name', None) - self.created_at = kwargs.get('created_at', None) - self.description = kwargs.get('description', None) - self.phone_plan_ids = kwargs.get('phone_plan_ids', None) + super(SearchRequest, self).__init__(**kwargs) + self.number_type = kwargs['number_type'] + self.assignment_type = kwargs['assignment_type'] + self.capabilities = kwargs['capabilities'] self.area_code = kwargs.get('area_code', None) - self.quantity = kwargs.get('quantity', 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) + self.quantity = kwargs.get('quantity', 1) -class PstnConfiguration(msrest.serialization.Model): - """Definition for pstn number configuration. +class SearchResult(msrest.serialization.Model): + """The result of a phone number search operation. All required parameters must be populated in order to send to Azure. - :param callback_url: Required. The webhook URL on the phone number configuration. - :type callback_url: str - :param application_id: The application id of the application to which to configure. - :type application_id: str - """ - - _validation = { - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'application_id': {'key': 'applicationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PstnConfiguration, self).__init__(**kwargs) - self.callback_url = kwargs['callback_url'] - self.application_id = kwargs.get('application_id', None) - - -class RateInformation(msrest.serialization.Model): - """Represents a wrapper of rate information. - - :param monthly_rate: The monthly rate of a phone plan group. - :type monthly_rate: float - :param currency_type: The currency of a phone plan group. Possible values include: "USD". - :type currency_type: str or ~azure.communication.administration.models.CurrencyType - :param rate_error_message: The error code of a phone plan group. - :type rate_error_message: str - """ - - _attribute_map = { - 'monthly_rate': {'key': 'monthlyRate', 'type': 'float'}, - 'currency_type': {'key': 'currencyType', 'type': 'str'}, - 'rate_error_message': {'key': 'rateErrorMessage', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RateInformation, self).__init__(**kwargs) - self.monthly_rate = kwargs.get('monthly_rate', None) - self.currency_type = kwargs.get('currency_type', None) - self.rate_error_message = kwargs.get('rate_error_message', None) - - -class ReleaseRequest(msrest.serialization.Model): - """Represents a release request. - - All required parameters must be populated in order to send to Azure. - - :param phone_numbers: Required. The list of phone numbers in the release request. + :param id: Required. The search id. + :type id: str + :param phone_numbers: Required. The phone numbers that are available. Can be fewer than the + desired search quantity. :type phone_numbers: list[str] + :param number_type: Required. The phoner number type. Possible values include: "tollFree", + "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities + :param monthly_rate: Required. The monthly cost for an individual phone number. + :type monthly_rate: ~azure.communication.administration.models.MonthlyRate + :param search_expires_by: Required. The date that this search result expires and phone numbers + are no longer on hold. A search result expires in less than 15min. + :type search_expires_by: ~datetime.datetime """ _validation = { + 'id': {'required': True}, 'phone_numbers': {'required': True}, + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'monthly_rate': {'required': True}, + 'search_expires_by': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, + 'monthly_rate': {'key': 'monthlyRate', 'type': 'MonthlyRate'}, + 'search_expires_by': {'key': 'searchExpiresBy', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(ReleaseRequest, self).__init__(**kwargs) + super(SearchResult, self).__init__(**kwargs) + self.id = kwargs['id'] self.phone_numbers = kwargs['phone_numbers'] - - -class ReleaseResponse(msrest.serialization.Model): - """Represents a release response. - - All required parameters must be populated in order to send to Azure. - - :param release_id: Required. The release id of a created release. - :type release_id: str - """ - - _validation = { - 'release_id': {'required': True}, - } - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReleaseResponse, self).__init__(**kwargs) - self.release_id = kwargs['release_id'] - - -class UpdateNumberCapabilitiesRequest(msrest.serialization.Model): - """Represents a numbers capabilities update request. - - All required parameters must be populated in order to send to Azure. - - :param phone_number_capabilities_update: Required. The map of phone numbers to the capabilities - update applied to the phone number. - :type phone_number_capabilities_update: dict[str, - ~azure.communication.administration.models.NumberUpdateCapabilities] - """ - - _validation = { - 'phone_number_capabilities_update': {'required': True}, - } - - _attribute_map = { - 'phone_number_capabilities_update': {'key': 'phoneNumberCapabilitiesUpdate', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateNumberCapabilitiesRequest, self).__init__(**kwargs) - self.phone_number_capabilities_update = kwargs['phone_number_capabilities_update'] - - -class UpdateNumberCapabilitiesResponse(msrest.serialization.Model): - """Represents a number capability update response. - - All required parameters must be populated in order to send to Azure. - - :param capabilities_update_id: Required. The capabilities id. - :type capabilities_update_id: str - """ - - _validation = { - 'capabilities_update_id': {'required': True}, - } - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = kwargs['capabilities_update_id'] - - -class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): - """Response for getting a phone number update capabilities. - - :param capabilities_update_id: The id of the phone number capabilities update. - :type capabilities_update_id: str - :param created_at: The time the capabilities update was created. - :type created_at: ~datetime.datetime - :param capabilities_update_status: Status of the capabilities update. Possible values include: - "Pending", "InProgress", "Complete", "Error". - :type capabilities_update_status: str or - ~azure.communication.administration.models.CapabilitiesUpdateStatus - :param phone_number_capabilities_updates: The capabilities update for each of a set of phone - numbers. - :type phone_number_capabilities_updates: dict[str, - ~azure.communication.administration.models.NumberUpdateCapabilities] - """ - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'capabilities_update_status': {'key': 'capabilitiesUpdateStatus', 'type': 'str'}, - 'phone_number_capabilities_updates': {'key': 'phoneNumberCapabilitiesUpdates', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdatePhoneNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = kwargs.get('capabilities_update_id', None) - self.created_at = kwargs.get('created_at', None) - self.capabilities_update_status = kwargs.get('capabilities_update_status', None) - self.phone_number_capabilities_updates = kwargs.get('phone_number_capabilities_updates', None) + self.number_type = kwargs['number_type'] + self.assignment_type = kwargs['assignment_type'] + self.capabilities = kwargs['capabilities'] + self.monthly_rate = kwargs['monthly_rate'] + self.search_expires_by = kwargs['search_expires_by'] 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 3ffd70177961..65ab96e77424 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 @@ -7,1191 +7,521 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._phone_number_administration_service_enums import * +from ._phone_number_administration_client_enums import * class AcquiredPhoneNumber(msrest.serialization.Model): - """Represents an acquired phone number. + """The acquired phone number and its metadata and configuration. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. String of the E.164 format of the phone number. + :param id: Required. The id, this is the same as the phone number in E.164 format. + :type id: str + :param phone_number: Required. The phoneNumber in E.164 format. :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 + :param country_code: Required. The ISO 3166-2 country code of the country that the phone number + belongs to. + :type country_code: str + :param number_type: Required. The type of the phone number. Possible values include: + "tollFree", "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The assignment type of the phone number, people or + application. Possible values include: "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param purchase_date: Required. The purchase date of the phone number. + :type purchase_date: ~datetime.datetime + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities + :param callback_url: Required. The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: Required. The application id the number has been assigned to. + :type application_id: str + :param monthly_rate: Required. The monthly cost of the phone number. + :type monthly_rate: ~azure.communication.administration.models.MonthlyRate """ _validation = { + 'id': {'required': True}, 'phone_number': {'required': True}, - 'acquired_capabilities': {'required': True}, - 'available_capabilities': {'required': True}, + 'country_code': {'required': True}, + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'purchase_date': {'required': True}, + 'capabilities': {'required': True}, + 'callback_url': {'required': True}, + 'application_id': {'required': True}, + 'monthly_rate': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'acquired_capabilities': {'key': 'acquiredCapabilities', 'type': '[str]'}, - 'available_capabilities': {'key': 'availableCapabilities', 'type': '[str]'}, - 'assignment_status': {'key': 'assignmentStatus', 'type': 'str'}, - 'place_name': {'key': 'placeName', 'type': 'str'}, - 'activation_state': {'key': 'activationState', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'purchase_date': {'key': 'purchaseDate', 'type': 'iso-8601'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'monthly_rate': {'key': 'monthlyRate', 'type': 'MonthlyRate'}, } def __init__( self, *, + id: str, phone_number: str, - acquired_capabilities: List[Union[str, "Capability"]], - available_capabilities: List[Union[str, "Capability"]], - assignment_status: Optional[Union[str, "AssignmentStatus"]] = None, - place_name: Optional[str] = None, - activation_state: Optional[Union[str, "ActivationState"]] = None, + country_code: str, + number_type: Union[str, "PhoneNumberType"], + assignment_type: Union[str, "AssignmentType"], + purchase_date: datetime.datetime, + capabilities: "Capabilities", + callback_url: str, + application_id: str, + monthly_rate: "MonthlyRate", **kwargs ): super(AcquiredPhoneNumber, self).__init__(**kwargs) + self.id = id self.phone_number = phone_number - self.acquired_capabilities = acquired_capabilities - self.available_capabilities = available_capabilities - self.assignment_status = assignment_status - self.place_name = place_name - self.activation_state = activation_state + self.country_code = country_code + self.number_type = number_type + self.assignment_type = assignment_type + self.purchase_date = purchase_date + self.capabilities = capabilities + self.callback_url = callback_url + self.application_id = application_id + self.monthly_rate = monthly_rate class AcquiredPhoneNumbers(msrest.serialization.Model): - """A wrapper of list of phone numbers. + """The list of acquired phone numbers. - :param phone_numbers: Represents a list of phone numbers. - :type phone_numbers: list[~azure.communication.administration.models.AcquiredPhoneNumber] + All required parameters must be populated in order to send to Azure. + + :param value: Required. Represents a list of acquired phone numbers. + :type value: 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'}, + _validation = { + 'value': {'required': True}, } - 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]'}, + 'value': {'key': 'value', 'type': '[AcquiredPhoneNumber]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, *, - primary_area_codes: Optional[List[str]] = None, - secondary_area_codes: Optional[List[str]] = None, + value: List["AcquiredPhoneNumber"], 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 + super(AcquiredPhoneNumbers, self).__init__(**kwargs) + self.value = value self.next_link = next_link -class CarrierDetails(msrest.serialization.Model): - """Represents carrier details. +class AcquiredPhoneNumberUpdate(msrest.serialization.Model): + """The properties of a phone number that can be changed. - :param name: Name of carrier details. - :type name: str - :param localized_name: Display name of carrier details. - :type localized_name: str + :param callback_url: The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: The application id the number has been assigned to. + :type application_id: str + :param capabilities: The new set of enabled capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, } def __init__( self, *, - name: Optional[str] = None, - localized_name: Optional[str] = None, + callback_url: Optional[str] = None, + application_id: Optional[str] = None, + capabilities: Optional["Capabilities"] = None, **kwargs ): - super(CarrierDetails, self).__init__(**kwargs) - self.name = name - self.localized_name = localized_name + super(AcquiredPhoneNumberUpdate, self).__init__(**kwargs) + self.callback_url = callback_url + self.application_id = application_id + self.capabilities = capabilities -class CreateSearchOptions(msrest.serialization.Model): - """Represents a search creation option. +class Capabilities(msrest.serialization.Model): + """The capabilities of a phone number. 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] + :param sms: Required. Available Sms capabilities. Possible values include: "inbound", + "outbound", "inbound+outbound", "none". Default value: "none". + :type sms: str or ~azure.communication.administration.models.CapabilityValue + :param calling: Required. Available Calling capabilities. Possible values include: "inbound", + "outbound", "inbound+outbound", "none". Default value: "none". + :type calling: str or ~azure.communication.administration.models.CapabilityValue """ _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}, + 'sms': {'required': True}, + 'calling': {'required': True}, } _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]'}, + 'sms': {'key': 'sms', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, } 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, + sms: Union[str, "CapabilityValue"] = "none", + calling: Union[str, "CapabilityValue"] = "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 + super(Capabilities, self).__init__(**kwargs) + self.sms = sms + self.calling = calling -class CreateSearchResponse(msrest.serialization.Model): - """Represents a search creation response. +class Error(msrest.serialization.Model): + """Represents a service error response body. + + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param search_id: Required. The search id of the search that was created. - :type search_id: str + :param code: Required. The error code in the error response. + :type code: str + :param message: Required. The error message in the error response. + :type message: str + :ivar inner_error: Represents a service error response body. + :vartype inner_error: ~azure.communication.administration.models.Error """ _validation = { - 'search_id': {'required': True}, + 'code': {'required': True}, + 'message': {'required': True}, + 'inner_error': {'readonly': 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'}, + 'inner_error': {'key': 'innererror', 'type': 'Error'}, } def __init__( self, *, - code: Optional[str] = None, - message: Optional[str] = None, + code: str, + message: str, **kwargs ): - super(ErrorBody, self).__init__(**kwargs) + super(Error, self).__init__(**kwargs) self.code = code self.message = message + self.inner_error = None class ErrorResponse(msrest.serialization.Model): """Represents a service error response. - :param error: Represents a service error response body. - :type error: ~azure.communication.administration.models.ErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorBody'}, - } - - def __init__( - self, - *, - error: Optional["ErrorBody"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class LocationOptions(msrest.serialization.Model): - """Represents a location options. - - :param label_id: The label id of the location. - :type label_id: str - :param label_name: The display name of the location. - :type label_name: str - :param options: The underlying location option details. - :type options: list[~azure.communication.administration.models.LocationOptionsDetails] - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'label_name': {'key': 'labelName', 'type': 'str'}, - 'options': {'key': 'options', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - *, - label_id: Optional[str] = None, - label_name: Optional[str] = None, - options: Optional[List["LocationOptionsDetails"]] = None, - **kwargs - ): - super(LocationOptions, self).__init__(**kwargs) - self.label_id = label_id - self.label_name = label_name - self.options = options - - -class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options details. - - :param name: The name of the location options. - :type name: str - :param value: The abbreviated name of the location options. - :type value: str - :param location_options: The underlying location options. - :type location_options: list[~azure.communication.administration.models.LocationOptions] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptions]'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - location_options: Optional[List["LocationOptions"]] = None, - **kwargs - ): - super(LocationOptionsDetails, self).__init__(**kwargs) - self.name = name - self.value = value - self.location_options = location_options - - -class LocationOptionsQueries(msrest.serialization.Model): - """Represents a list of location option queries, used for fetching area codes. - - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.administration.models.LocationOptionsQuery] - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsQuery]'}, - } - - def __init__( - self, - *, - location_options: Optional[List["LocationOptionsQuery"]] = None, - **kwargs - ): - super(LocationOptionsQueries, self).__init__(**kwargs) - self.location_options = location_options - - -class LocationOptionsQuery(msrest.serialization.Model): - """Represents a location options parameter, used for fetching area codes. - - :param label_id: Represents the location option label id, returned from the GetLocationOptions - API. - :type label_id: str - :param options_value: Represents the location options value, returned from the - GetLocationOptions API. - :type options_value: str - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'options_value': {'key': 'optionsValue', 'type': 'str'}, - } - - def __init__( - self, - *, - label_id: Optional[str] = None, - options_value: Optional[str] = None, - **kwargs - ): - super(LocationOptionsQuery, self).__init__(**kwargs) - self.label_id = label_id - self.options_value = options_value - - -class LocationOptionsResponse(msrest.serialization.Model): - """Represents a wrapper around a list of location options. - - :param location_options: Represents a location options. - :type location_options: ~azure.communication.administration.models.LocationOptions - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': 'LocationOptions'}, - } - - def __init__( - self, - *, - location_options: Optional["LocationOptions"] = None, - **kwargs - ): - super(LocationOptionsResponse, self).__init__(**kwargs) - self.location_options = location_options - - -class NumberConfiguration(msrest.serialization.Model): - """Definition for number configuration. - All required parameters must be populated in order to send to Azure. - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.models.PstnConfiguration - :param phone_number: Required. The phone number to configure. - :type phone_number: str + :param error: Required. Represents a service error response body. + :type error: ~azure.communication.administration.models.Error """ _validation = { - 'pstn_configuration': {'required': True}, - 'phone_number': {'required': True}, + 'error': {'required': True}, } _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, } def __init__( self, *, - pstn_configuration: "PstnConfiguration", - phone_number: str, + error: "Error", **kwargs ): - super(NumberConfiguration, self).__init__(**kwargs) - self.pstn_configuration = pstn_configuration - self.phone_number = phone_number + super(ErrorResponse, self).__init__(**kwargs) + self.error = error -class NumberConfigurationPhoneNumber(msrest.serialization.Model): - """The phone number wrapper representing a number configuration request. +class MonthlyRate(msrest.serialization.Model): + """The monthly incurred cost for a single phone number. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. The phone number in the E.164 format. - :type phone_number: str + :param value: Required. The cost amount. + :type value: float + :param currency: Required. The currency of the cost amount. + :type currency: str """ _validation = { - 'phone_number': {'required': True}, + 'value': {'required': True}, + 'currency': {'required': True}, } _attribute_map = { - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'currency': {'key': 'currency', 'type': 'str'}, } def __init__( self, *, - phone_number: str, + value: float, + currency: str, **kwargs ): - super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) - self.phone_number = phone_number + super(MonthlyRate, self).__init__(**kwargs) + self.value = value + self.currency = currency -class NumberConfigurationResponse(msrest.serialization.Model): - """Definition for number configuration. +class Operation(msrest.serialization.Model): + """Long running operation. 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 status: Required. Status of operation. Possible values include: "notStarted", "running", + "succeeded", "failed". + :type status: str or ~azure.communication.administration.models.OperationStatusCodes + :param id: Required. Id of the operation. + :type id: str + :param kind: Required. Kind of the operation. Possible values include: "search", "purchase", + "releasePhoneNumber", "updatePhoneNumber". + :type kind: str or ~azure.communication.administration.models.OperationKind + :param created_date_time: Required. The date that the operation was created. + :type created_date_time: ~datetime.datetime + :param last_action_date_time: Required. The most recent date that the operation was changed. + :type last_action_date_time: ~datetime.datetime + :param resource_location: Url for retrieving the result of the operation if any. + :type resource_location: str + :param error: Represents a service error response body. + :type error: ~azure.communication.administration.models.Error """ _validation = { - 'pstn_configuration': {'required': True}, + 'status': {'required': True}, + 'id': {'required': True}, + 'kind': {'required': True}, + 'created_date_time': {'required': True}, + 'last_action_date_time': {'required': True}, } _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + 'status': {'key': 'status', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, } def __init__( self, *, - pstn_configuration: "PstnConfiguration", + status: Union[str, "OperationStatusCodes"], + id: str, + kind: Union[str, "OperationKind"], + created_date_time: datetime.datetime, + last_action_date_time: datetime.datetime, + resource_location: Optional[str] = None, + error: Optional["Error"] = None, **kwargs ): - super(NumberConfigurationResponse, self).__init__(**kwargs) - self.pstn_configuration = pstn_configuration + super(Operation, self).__init__(**kwargs) + self.status = status + self.id = id + self.kind = kind + self.created_date_time = created_date_time + self.last_action_date_time = last_action_date_time + self.resource_location = resource_location + self.error = error -class NumberUpdateCapabilities(msrest.serialization.Model): - """Represents an individual number capabilities update request. +class PurchaseRequest(msrest.serialization.Model): + """Request to purchase phone numbers. - :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] + :param search_id: The id of the search result to purchase. + :type search_id: str """ _attribute_map = { - 'add': {'key': 'add', 'type': '[str]'}, - 'remove': {'key': 'remove', 'type': '[str]'}, + 'search_id': {'key': 'searchId', 'type': 'str'}, } def __init__( self, *, - add: Optional[List[Union[str, "Capability"]]] = None, - remove: Optional[List[Union[str, "Capability"]]] = None, + search_id: Optional[str] = None, **kwargs ): - super(NumberUpdateCapabilities, self).__init__(**kwargs) - self.add = add - self.remove = remove + super(PurchaseRequest, self).__init__(**kwargs) + self.search_id = search_id -class PhoneNumberCountries(msrest.serialization.Model): - """Represents a wrapper around a list of countries. +class SearchCapabilities(msrest.serialization.Model): + """The capabilities of a phone number. - :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 + :param sms: Available Sms capabilities. Possible values include: "inbound", "outbound", + "inbound+outbound", "none". Default value: "none". + :type sms: str or ~azure.communication.administration.models.CapabilityValue + :param calling: Available Calling capabilities. Possible values include: "inbound", "outbound", + "inbound+outbound", "none". Default value: "none". + :type calling: str or ~azure.communication.administration.models.CapabilityValue """ _attribute_map = { - 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, } def __init__( self, *, - countries: Optional[List["PhoneNumberCountry"]] = None, - next_link: Optional[str] = None, + sms: Optional[Union[str, "CapabilityValue"]] = "none", + calling: Optional[Union[str, "CapabilityValue"]] = "none", **kwargs ): - super(PhoneNumberCountries, self).__init__(**kwargs) - self.countries = countries - self.next_link = next_link + super(SearchCapabilities, self).__init__(**kwargs) + self.sms = sms + self.calling = calling -class PhoneNumberCountry(msrest.serialization.Model): - """Represents a country. +class SearchRequest(msrest.serialization.Model): + """The desired properties of a phone number for search. All required parameters must be populated in order to send to Azure. - :param localized_name: Required. Represents the name of the country. - :type localized_name: str - :param country_code: Required. Represents the abbreviated name of the country. - :type country_code: str - """ - - _validation = { - 'localized_name': {'required': True}, - 'country_code': {'required': True}, - } - - _attribute_map = { - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - } - - def __init__( - self, - *, - localized_name: str, - country_code: str, - **kwargs - ): - super(PhoneNumberCountry, self).__init__(**kwargs) - self.localized_name = localized_name - self.country_code = country_code - - -class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searches or releases, as part of the response when fetching all searches or releases. - - :param entities: The underlying list of entities. - :type entities: list[~azure.communication.administration.models.PhoneNumberEntity] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'entities': {'key': 'entities', 'type': '[PhoneNumberEntity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - entities: Optional[List["PhoneNumberEntity"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhoneNumberEntities, self).__init__(**kwargs) - self.entities = entities - self.next_link = next_link - - -class PhoneNumberEntity(msrest.serialization.Model): - """Represents a phone number entity, as part of the response when calling get all searches or releases. - - :param id: The id of the entity. It is the search id of a search. It is the release id of a - release. - :type id: str - :param created_at: Date and time the entity is created. - :type created_at: ~datetime.datetime - :param display_name: Name of the entity. - :type display_name: str - :param quantity: Quantity of requested phone numbers in the entity. + :param number_type: Required. The phone number type. Possible values include: "tollFree", + "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.SearchCapabilities + :param area_code: The desired area code. + :type area_code: str + :param quantity: The desired quantity of phone numbers. :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'}, + _validation = { + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, } - def __init__( - self, - *, - status: Optional[Union[str, "PhoneNumberReleaseStatus"]] = None, - error_code: Optional[int] = None, - **kwargs - ): - super(PhoneNumberReleaseDetails, self).__init__(**kwargs) - self.status = status - self.error_code = error_code - - -class PhoneNumberReservation(msrest.serialization.Model): - """Represents a phone number search. - - :param reservation_id: The id of the search. - :type reservation_id: str - :param display_name: The name of the search. - :type display_name: str - :param created_at: The creation time of the search. - :type created_at: ~datetime.datetime - :param description: The description of the search. - :type description: str - :param phone_plan_ids: The phone plan ids of the search. - :type phone_plan_ids: list[str] - :param area_code: The area code of the search. - :type area_code: str - :param quantity: The quantity of phone numbers in the search. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.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 = { - 'reservation_id': {'key': 'searchId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'SearchCapabilities'}, '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, *, - reservation_id: Optional[str] = None, - display_name: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - description: Optional[str] = None, - phone_plan_ids: Optional[List[str]] = None, + number_type: Union[str, "PhoneNumberType"], + assignment_type: Union[str, "AssignmentType"], + capabilities: "SearchCapabilities", 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, + quantity: Optional[int] = 1, **kwargs ): - super(PhoneNumberReservation, self).__init__(**kwargs) - self.reservation_id = reservation_id - self.display_name = display_name - self.created_at = created_at - self.description = description - self.phone_plan_ids = phone_plan_ids + super(SearchRequest, self).__init__(**kwargs) + self.number_type = number_type + self.assignment_type = assignment_type + self.capabilities = capabilities 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. +class SearchResult(msrest.serialization.Model): + """The result of a phone number search operation. All required parameters must be populated in order to send to Azure. - :param phone_plan_group_id: Required. The id of the plan group. - :type phone_plan_group_id: str - :param phone_number_type: The phone number type of the plan group. Possible values include: - "Unknown", "Geographic", "TollFree", "Indirect". - :type phone_number_type: str or ~azure.communication.administration.models.PhoneNumberType - :param localized_name: Required. The name of the plan group. - :type localized_name: str - :param localized_description: Required. The description of the plan group. - :type localized_description: str - :param carrier_details: Represents carrier details. - :type carrier_details: ~azure.communication.administration.models.CarrierDetails - :param rate_information: Represents a wrapper of rate information. - :type rate_information: ~azure.communication.administration.models.RateInformation - """ - - _validation = { - 'phone_plan_group_id': {'required': True}, - 'localized_name': {'required': True}, - 'localized_description': {'required': True}, - } - - _attribute_map = { - 'phone_plan_group_id': {'key': 'phonePlanGroupId', 'type': 'str'}, - 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'localized_description': {'key': 'localizedDescription', 'type': 'str'}, - 'carrier_details': {'key': 'carrierDetails', 'type': 'CarrierDetails'}, - 'rate_information': {'key': 'rateInformation', 'type': 'RateInformation'}, - } - - def __init__( - self, - *, - phone_plan_group_id: str, - localized_name: str, - localized_description: str, - phone_number_type: Optional[Union[str, "PhoneNumberType"]] = None, - carrier_details: Optional["CarrierDetails"] = None, - rate_information: Optional["RateInformation"] = None, - **kwargs - ): - super(PhonePlanGroup, self).__init__(**kwargs) - self.phone_plan_group_id = phone_plan_group_id - self.phone_number_type = phone_number_type - self.localized_name = localized_name - self.localized_description = localized_description - self.carrier_details = carrier_details - self.rate_information = rate_information - - -class PhonePlanGroups(msrest.serialization.Model): - """Represents a wrapper of list of plan groups. - - :param phone_plan_groups: The underlying list of phone plan groups. - :type phone_plan_groups: list[~azure.communication.administration.models.PhonePlanGroup] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plan_groups': {'key': 'phonePlanGroups', 'type': '[PhonePlanGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - phone_plan_groups: Optional[List["PhonePlanGroup"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhonePlanGroups, self).__init__(**kwargs) - self.phone_plan_groups = phone_plan_groups - self.next_link = next_link - - -class PhonePlansResponse(msrest.serialization.Model): - """Represents a wrapper around a list of countries. - - :param phone_plans: Represents the underlying list of phone plans. - :type phone_plans: list[~azure.communication.administration.models.PhonePlan] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plans': {'key': 'phonePlans', 'type': '[PhonePlan]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - phone_plans: Optional[List["PhonePlan"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhonePlansResponse, self).__init__(**kwargs) - self.phone_plans = phone_plans - self.next_link = next_link - - -class PstnConfiguration(msrest.serialization.Model): - """Definition for pstn number configuration. - - All required parameters must be populated in order to send to Azure. - - :param callback_url: Required. The webhook URL on the phone number configuration. - :type callback_url: str - :param application_id: The application id of the application to which to configure. - :type application_id: str - """ - - _validation = { - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'application_id': {'key': 'applicationId', 'type': 'str'}, - } - - def __init__( - self, - *, - callback_url: str, - application_id: Optional[str] = None, - **kwargs - ): - super(PstnConfiguration, self).__init__(**kwargs) - self.callback_url = callback_url - self.application_id = application_id - - -class RateInformation(msrest.serialization.Model): - """Represents a wrapper of rate information. - - :param monthly_rate: The monthly rate of a phone plan group. - :type monthly_rate: float - :param currency_type: The currency of a phone plan group. Possible values include: "USD". - :type currency_type: str or ~azure.communication.administration.models.CurrencyType - :param rate_error_message: The error code of a phone plan group. - :type rate_error_message: str - """ - - _attribute_map = { - 'monthly_rate': {'key': 'monthlyRate', 'type': 'float'}, - 'currency_type': {'key': 'currencyType', 'type': 'str'}, - 'rate_error_message': {'key': 'rateErrorMessage', 'type': 'str'}, - } - - def __init__( - self, - *, - monthly_rate: Optional[float] = None, - currency_type: Optional[Union[str, "CurrencyType"]] = None, - rate_error_message: Optional[str] = None, - **kwargs - ): - super(RateInformation, self).__init__(**kwargs) - self.monthly_rate = monthly_rate - self.currency_type = currency_type - self.rate_error_message = rate_error_message - - -class ReleaseRequest(msrest.serialization.Model): - """Represents a release request. - - All required parameters must be populated in order to send to Azure. - - :param phone_numbers: Required. The list of phone numbers in the release request. + :param id: Required. The search id. + :type id: str + :param phone_numbers: Required. The phone numbers that are available. Can be fewer than the + desired search quantity. :type phone_numbers: list[str] + :param number_type: Required. The phoner number type. Possible values include: "tollFree", + "geographic". + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: Required. The phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: Required. The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities + :param monthly_rate: Required. The monthly cost for an individual phone number. + :type monthly_rate: ~azure.communication.administration.models.MonthlyRate + :param search_expires_by: Required. The date that this search result expires and phone numbers + are no longer on hold. A search result expires in less than 15min. + :type search_expires_by: ~datetime.datetime """ _validation = { + 'id': {'required': True}, 'phone_numbers': {'required': True}, + 'number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'monthly_rate': {'required': True}, + 'search_expires_by': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + 'number_type': {'key': 'numberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'Capabilities'}, + 'monthly_rate': {'key': 'monthlyRate', 'type': 'MonthlyRate'}, + 'search_expires_by': {'key': 'searchExpiresBy', 'type': 'iso-8601'}, } def __init__( self, *, + id: str, phone_numbers: List[str], + number_type: Union[str, "PhoneNumberType"], + assignment_type: Union[str, "AssignmentType"], + capabilities: "Capabilities", + monthly_rate: "MonthlyRate", + search_expires_by: datetime.datetime, **kwargs ): - super(ReleaseRequest, self).__init__(**kwargs) + super(SearchResult, self).__init__(**kwargs) + self.id = id self.phone_numbers = phone_numbers - - -class ReleaseResponse(msrest.serialization.Model): - """Represents a release response. - - All required parameters must be populated in order to send to Azure. - - :param release_id: Required. The release id of a created release. - :type release_id: str - """ - - _validation = { - 'release_id': {'required': True}, - } - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - } - - def __init__( - self, - *, - release_id: str, - **kwargs - ): - super(ReleaseResponse, self).__init__(**kwargs) - self.release_id = release_id - - -class UpdateNumberCapabilitiesRequest(msrest.serialization.Model): - """Represents a numbers capabilities update request. - - All required parameters must be populated in order to send to Azure. - - :param phone_number_capabilities_update: Required. The map of phone numbers to the capabilities - update applied to the phone number. - :type phone_number_capabilities_update: dict[str, - ~azure.communication.administration.models.NumberUpdateCapabilities] - """ - - _validation = { - 'phone_number_capabilities_update': {'required': True}, - } - - _attribute_map = { - 'phone_number_capabilities_update': {'key': 'phoneNumberCapabilitiesUpdate', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - *, - phone_number_capabilities_update: Dict[str, "NumberUpdateCapabilities"], - **kwargs - ): - super(UpdateNumberCapabilitiesRequest, self).__init__(**kwargs) - self.phone_number_capabilities_update = phone_number_capabilities_update - - -class UpdateNumberCapabilitiesResponse(msrest.serialization.Model): - """Represents a number capability update response. - - All required parameters must be populated in order to send to Azure. - - :param capabilities_update_id: Required. The capabilities id. - :type capabilities_update_id: str - """ - - _validation = { - 'capabilities_update_id': {'required': True}, - } - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - } - - def __init__( - self, - *, - capabilities_update_id: str, - **kwargs - ): - super(UpdateNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = capabilities_update_id - - -class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): - """Response for getting a phone number update capabilities. - - :param capabilities_update_id: The id of the phone number capabilities update. - :type capabilities_update_id: str - :param created_at: The time the capabilities update was created. - :type created_at: ~datetime.datetime - :param capabilities_update_status: Status of the capabilities update. Possible values include: - "Pending", "InProgress", "Complete", "Error". - :type capabilities_update_status: str or - ~azure.communication.administration.models.CapabilitiesUpdateStatus - :param phone_number_capabilities_updates: The capabilities update for each of a set of phone - numbers. - :type phone_number_capabilities_updates: dict[str, - ~azure.communication.administration.models.NumberUpdateCapabilities] - """ - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'capabilities_update_status': {'key': 'capabilitiesUpdateStatus', 'type': 'str'}, - 'phone_number_capabilities_updates': {'key': 'phoneNumberCapabilitiesUpdates', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - *, - capabilities_update_id: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - capabilities_update_status: Optional[Union[str, "CapabilitiesUpdateStatus"]] = None, - phone_number_capabilities_updates: Optional[Dict[str, "NumberUpdateCapabilities"]] = None, - **kwargs - ): - super(UpdatePhoneNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = capabilities_update_id - self.created_at = created_at - self.capabilities_update_status = capabilities_update_status - self.phone_number_capabilities_updates = phone_number_capabilities_updates + self.number_type = number_type + self.assignment_type = assignment_type + self.capabilities = capabilities + self.monthly_rate = monthly_rate + self.search_expires_by = search_expires_by diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_client_enums.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_client_enums.py new file mode 100644 index 000000000000..ca95f20fb2e3 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_client_enums.py @@ -0,0 +1,68 @@ +# 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 AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type that the phone number can be assigned to. + """ + + PERSON = "person" + APPLICATION = "application" + +class CapabilityValue(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The possible values for a phone number capability. + """ + + INBOUND = "inbound" + OUTBOUND = "outbound" + INBOUND_OUTBOUND = "inbound+outbound" + NONE = "none" + +class OperationKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Kind of the operation. + """ + + SEARCH = "search" + PURCHASE = "purchase" + RELEASE_PHONE_NUMBER = "releasePhoneNumber" + UPDATE_PHONE_NUMBER = "updatePhoneNumber" + +class OperationStatusCodes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status code of the operation. + """ + + NOT_STARTED = "notStarted" + RUNNING = "running" + SUCCEEDED = "succeeded" + FAILED = "failed" + +class PhoneNumberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of a phone number. + """ + + TOLL_FREE = "tollFree" + GEOGRAPHIC = "geographic" 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 deleted file mode 100644 index 5b53cc8756be..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_service_enums.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActivationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The activation state of the phone number. Can be "Activated", "AssignmentPending", - "AssignmentFailed", "UpdatePending", "UpdateFailed" - """ - - ACTIVATED = "Activated" - ASSIGNMENT_PENDING = "AssignmentPending" - ASSIGNMENT_FAILED = "AssignmentFailed" - UPDATE_PENDING = "UpdatePending" - UPDATE_FAILED = "UpdateFailed" - -class AssignmentStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The assignment status of the phone number. Conveys what type of entity the number is assigned - to. - """ - - UNASSIGNED = "Unassigned" - UNKNOWN = "Unknown" - USER_ASSIGNED = "UserAssigned" - CONFERENCE_ASSIGNED = "ConferenceAssigned" - FIRST_PARTY_APP_ASSIGNED = "FirstPartyAppAssigned" - THIRD_PARTY_APP_ASSIGNED = "ThirdPartyAppAssigned" - -class CapabilitiesUpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the capabilities update. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - COMPLETE = "Complete" - ERROR = "Error" - -class Capability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Represents the capabilities of a phone number. - """ - - USER_ASSIGNMENT = "UserAssignment" - FIRST_PARTY_VOICE_APP_ASSIGNMENT = "FirstPartyVoiceAppAssignment" - CONFERENCE_ASSIGNMENT = "ConferenceAssignment" - P2_P_SMS_ENABLED = "P2PSmsEnabled" - GEOGRAPHIC = "Geographic" - NON_GEOGRAPHIC = "NonGeographic" - TOLL_CALLING = "TollCalling" - TOLL_FREE_CALLING = "TollFreeCalling" - PREMIUM = "Premium" - P2_P_SMS_CAPABLE = "P2PSmsCapable" - A2_P_SMS_CAPABLE = "A2PSmsCapable" - A2_P_SMS_ENABLED = "A2PSmsEnabled" - CALLING = "Calling" - TOLL_FREE = "TollFree" - FIRST_PARTY_APP_ASSIGNMENT = "FirstPartyAppAssignment" - THIRD_PARTY_APP_ASSIGNMENT = "ThirdPartyAppAssignment" - AZURE = "Azure" - OFFICE365 = "Office365" - INBOUND_CALLING = "InboundCalling" - OUTBOUND_CALLING = "OutboundCalling" - INBOUND_A2_P_SMS = "InboundA2PSms" - OUTBOUND_A2_P_SMS = "OutboundA2PSms" - INBOUND_P2_P_SMS = "InboundP2PSms" - OUTBOUND_P2_P_SMS = "OutboundP2PSms" - -class CurrencyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The currency of a phone plan group - """ - - USD = "USD" - -class LocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The location type of the phone plan. - """ - - CIVIC_ADDRESS = "CivicAddress" - NOT_REQUIRED = "NotRequired" - SELECTION = "Selection" - -class PhoneNumberReleaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The release status of a phone number. - """ - - PENDING = "Pending" - SUCCESS = "Success" - ERROR = "Error" - IN_PROGRESS = "InProgress" - -class PhoneNumberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The phone number type of the plan group - """ - - UNKNOWN = "Unknown" - GEOGRAPHIC = "Geographic" - TOLL_FREE = "TollFree" - INDIRECT = "Indirect" - -class ReleaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The release status. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - COMPLETE = "Complete" - FAILED = "Failed" - EXPIRED = "Expired" - -class SearchStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the search. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - RESERVED = "Reserved" - EXPIRED = "Expired" - EXPIRING = "Expiring" - COMPLETING = "Completing" - REFRESHING = "Refreshing" - SUCCESS = "Success" - MANUAL = "Manual" - CANCELLED = "Cancelled" - CANCELLING = "Cancelling" - ERROR = "Error" - PURCHASE_PENDING = "PurchasePending" diff --git a/sdk/communication/azure-communication-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 894068bfa259..9f4b49db53cc 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 @@ -12,12 +12,14 @@ from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling from .. import models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,853 +46,166 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def get_all_phone_numbers( - self, - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.AcquiredPhoneNumbers"] - """Gets the list of the acquired phone numbers. - - Gets the list of the acquired phone numbers. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.models.AcquiredPhoneNumbers] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumbers"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_all_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) - list_of_elem = deserialized.phone_numbers - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_phone_numbers.metadata = {'url': '/administration/phonenumbers/phonenumbers'} # type: ignore - - def get_all_area_codes( - self, - location_type, # type: str - country_code, # type: str - phone_plan_id, # type: str - location_options=None, # type: Optional[List["models.LocationOptionsQuery"]] - **kwargs # type: Any - ): - # type: (...) -> "models.AreaCodes" - """Gets a list of the supported area codes. - - Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.administration.models.LocationOptionsQuery] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AreaCodes, or the result of cls(response) - :rtype: ~azure.communication.administration.models.AreaCodes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AreaCodes"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.LocationOptionsQueries(location_options=location_options) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.get_all_area_codes.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['locationType'] = self._serialize.query("location_type", location_type, 'str') - query_parameters['phonePlanId'] = self._serialize.query("phone_plan_id", phone_plan_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'LocationOptionsQueries') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AreaCodes', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_all_area_codes.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/areacodes'} # type: ignore - - def get_capabilities_update( - self, - capabilities_update_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.UpdatePhoneNumberCapabilitiesResponse" - """Get capabilities by capabilities update id. - - Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdatePhoneNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.UpdatePhoneNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.UpdatePhoneNumberCapabilitiesResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - # Construct URL - url = self.get_capabilities_update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'capabilitiesUpdateId': self._serialize.url("capabilities_update_id", capabilities_update_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdatePhoneNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_capabilities_update.metadata = {'url': '/administration/phonenumbers/capabilities/{capabilitiesUpdateId}'} # type: ignore - - def update_capabilities( - self, - phone_number_capabilities_update, # type: Dict[str, "models.NumberUpdateCapabilities"] - **kwargs # type: Any - ): - # type: (...) -> "models.UpdateNumberCapabilitiesResponse" - """Adds or removes phone number capabilities. - - Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: dict[str, ~azure.communication.administration.models.NumberUpdateCapabilities] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.UpdateNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.UpdateNumberCapabilitiesResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.UpdateNumberCapabilitiesRequest(phone_number_capabilities_update=phone_number_capabilities_update) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'UpdateNumberCapabilitiesRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_capabilities.metadata = {'url': '/administration/phonenumbers/capabilities'} # type: ignore - - def get_all_supported_countries( - self, - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.PhoneNumberCountries"] - """Gets a list of supported countries. - - Gets a list of supported countries. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberCountries or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.models.PhoneNumberCountries] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberCountries"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_all_supported_countries.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberCountries', pipeline_response) - list_of_elem = deserialized.countries - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_supported_countries.metadata = {'url': '/administration/phonenumbers/countries'} # type: ignore - - def get_number_configuration( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.NumberConfigurationResponse" - """Endpoint for getting number configurations. - - Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NumberConfigurationResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.NumberConfigurationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.NumberConfigurationResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.get_number_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('NumberConfigurationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_number_configuration.metadata = {'url': '/administration/phonenumbers/numberconfiguration'} # type: ignore - - def configure_number( - self, - pstn_configuration, # type: "models.PstnConfiguration" - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for configuring a pstn number. - - Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.models.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfiguration(pstn_configuration=pstn_configuration, phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.configure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfiguration') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - configure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/configure'} # type: ignore - - def unconfigure_number( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for unconfiguring a pstn number by removing the configuration. - - Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.unconfigure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unconfigure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/unconfigure'} # type: ignore - - def get_phone_plan_groups( - self, - country_code, # type: str - locale="en-US", # type: Optional[str] - include_rate_information=False, # type: Optional[bool] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.PhonePlanGroups"] - """Gets a list of phone plan groups for the given country. - - Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param include_rate_information: - :type include_rate_information: bool - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlanGroups or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.models.PhonePlanGroups] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlanGroups"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_phone_plan_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if include_rate_information is not None: - query_parameters['includeRateInformation'] = self._serialize.query("include_rate_information", include_rate_information, 'bool') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlanGroups', pipeline_response) - list_of_elem = deserialized.phone_plan_groups - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_phone_plan_groups.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups'} # type: ignore - - def get_phone_plans( - self, - country_code, # type: str - phone_plan_group_id, # type: str - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.PhonePlansResponse"] - """Gets a list of phone plans for a phone plan group. - - Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlansResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.models.PhonePlansResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlansResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.get_phone_plans.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlansResponse', pipeline_response) - list_of_elem = deserialized.phone_plans - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_phone_plans.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans'} # type: ignore - - def get_phone_plan_location_options( + def _search_available_phone_numbers_initial( self, country_code, # type: str - phone_plan_group_id, # type: str - phone_plan_id, # type: str - locale="en-US", # type: Optional[str] + number_type, # type: Union[str, "models.PhoneNumberType"] + assignment_type, # type: Union[str, "models.AssignmentType"] + capabilities, # type: "models.SearchCapabilities" + area_code=None, # type: Optional[str] + quantity=1, # type: Optional[int] **kwargs # type: Any ): - # type: (...) -> "models.LocationOptionsResponse" - """Gets a list of location options for a phone plan. - - Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationOptionsResponse, or the result of cls(response) - :rtype: ~azure.communication.administration.models.LocationOptionsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationOptionsResponse"] + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) + + _search = models.SearchRequest(number_type=number_type, assignment_type=assignment_type, capabilities=capabilities, area_code=area_code, quantity=quantity) api_version = "2020-07-20-preview1" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.get_phone_plan_location_options.metadata['url'] # type: ignore + url = self._search_available_phone_numbers_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'countryCode': self._serialize.url("country_code", country_code, 'str'), - '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' + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_search, 'SearchRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - 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]: + 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) - deserialized = self._deserialize('LocationOptionsResponse', pipeline_response) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - get_phone_plan_location_options.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions'} # type: ignore + _search_available_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/~search'} # type: ignore + + def begin_search_available_phone_numbers( + self, + country_code, # type: str + number_type, # type: Union[str, "models.PhoneNumberType"] + assignment_type, # type: Union[str, "models.AssignmentType"] + capabilities, # type: "models.SearchCapabilities" + area_code=None, # type: Optional[str] + quantity=1, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Search for available phone numbers to purchase. + + Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code. + :type country_code: str + :param number_type: The phone number type. + :type number_type: str or ~azure.communication.administration.models.PhoneNumberType + :param assignment_type: The phone number's assignment type. + :type assignment_type: str or ~azure.communication.administration.models.AssignmentType + :param capabilities: The phone number's capabilities. + :type capabilities: ~azure.communication.administration.models.SearchCapabilities + :param area_code: The desired area code. + :type area_code: str + :param quantity: The desired quantity of phone numbers. + :type quantity: int + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._search_available_phone_numbers_initial( + country_code=country_code, + number_type=number_type, + assignment_type=assignment_type, + capabilities=capabilities, + area_code=area_code, + quantity=quantity, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_search_available_phone_numbers.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/~search'} # type: ignore - def get_release_by_id( + def get_search_result( self, - release_id, # type: str + search_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.PhoneNumberRelease" - """Gets a release by a release id. + # type: (...) -> "models.SearchResult" + """Get a search result by its id. - Gets a release by a release id. + Get a search result by its id. - :param release_id: Represents the release id. - :type release_id: str + :param search_id: The search Id. + :type search_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberRelease, or the result of cls(response) - :rtype: ~azure.communication.administration.models.PhoneNumberRelease + :return: SearchResult, or the result of cls(response) + :rtype: ~azure.communication.administration.models.SearchResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberRelease"] + cls = kwargs.pop('cls', None) # type: ClsType["models.SearchResult"] 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 + url = self.get_search_result.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'releaseId': self._serialize.url("release_id", release_id, 'str'), + 'searchId': self._serialize.url("search_id", search_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -911,41 +226,30 @@ def get_release_by_id( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('PhoneNumberRelease', pipeline_response) + deserialized = self._deserialize('SearchResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_release_by_id.metadata = {'url': '/administration/phonenumbers/releases/{releaseId}'} # type: ignore + get_search_result.metadata = {'url': '/availablePhoneNumbers/searchResults/{searchId}'} # type: ignore - def release_phone_numbers( + def _purchase_phone_numbers_initial( self, - phone_numbers, # type: List[str] + search_id=None, # type: Optional[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"] + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - _body = models.ReleaseRequest(phone_numbers=phone_numbers) + _purchase = models.PurchaseRequest(search_id=search_id) 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 + url = self._purchase_phone_numbers_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -958,140 +262,112 @@ def release_phone_numbers( # 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 = self._serialize.body(_purchase, 'PurchaseRequest') 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]: + 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) - deserialized = self._deserialize('ReleaseResponse', pipeline_response) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - release_phone_numbers.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore + _purchase_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/~purchase'} # type: ignore - def get_all_releases( + def begin_purchase_phone_numbers( self, - skip=0, # type: Optional[int] - take=100, # type: Optional[int] + search_id=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> Iterable["models.PhoneNumberEntities"] - """Gets a list of all releases. + # type: (...) -> LROPoller[None] + """Purchase phone numbers. - Gets a list of all releases. + Purchase phone numbers. - :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 + :param search_id: The id of the search result to purchase. + :type search_id: str :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - 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 + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - get_all_releases.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._purchase_phone_numbers_initial( + search_id=search_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase_phone_numbers.metadata = {'url': '/availablePhoneNumbers/~purchase'} # type: ignore - def get_search_by_id( + def get_operation( self, - search_id, # type: str + operation_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.PhoneNumberReservation" - """Get search by search id. + # type: (...) -> "models.Operation" + """Get an operation by its id. - Get search by search id. + Get an operation by its id. - :param search_id: The search id to be searched for. - :type search_id: str + :param operation_id: The operation Id. + :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberReservation, or the result of cls(response) - :rtype: ~azure.communication.administration.models.PhoneNumberReservation + :return: Operation, or the result of cls(response) + :rtype: ~azure.communication.administration.models.Operation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberReservation"] + cls = kwargs.pop('cls', None) # type: ClsType["models.Operation"] 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 + url = self.get_operation.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1112,41 +388,41 @@ def get_search_by_id( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('PhoneNumberReservation', pipeline_response) + deserialized = self._deserialize('Operation', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_search_by_id.metadata = {'url': '/administration/phonenumbers/searches/{searchId}'} # type: ignore + get_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore - def create_search( + def cancel_operation( self, - body=None, # type: Optional["models.CreateSearchOptions"] + operation_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.CreateSearchResponse" - """Creates a phone number search. + # type: (...) -> None + """Cancels the operation if cancellation is supported for the operation type. - Creates a phone number search. + Cancels the operation if cancellation is supported for the operation type. - :param body: Defines the search options. - :type body: ~azure.communication.administration.models.CreateSearchOptions + :param operation_id: The operation Id. + :type operation_id: str :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 + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CreateSearchResponse"] + 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" - content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_search.metadata['url'] # type: ignore + url = self.cancel_operation.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1156,54 +432,36 @@ def create_search( # 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) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [201]: + 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('CreateSearchResponse', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - create_search.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore + cancel_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore - def get_all_searches( + def list_phone_numbers( self, - skip=0, # type: Optional[int] - take=100, # type: Optional[int] **kwargs # type: Any ): - # type: (...) -> Iterable["models.PhoneNumberEntities"] - """Gets a list of all searches. + # type: (...) -> Iterable["models.AcquiredPhoneNumbers"] + """Lists acquired phone numbers. - Gets a list of all searches. + Lists acquired phone numbers. - :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] + :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.PhoneNumberEntities"] + 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" @@ -1215,17 +473,13 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.get_all_searches.metadata['url'] # type: ignore + url = self.list_phone_numbers.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if 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) @@ -1240,8 +494,8 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities + deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) + list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) @@ -1262,35 +516,86 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - get_all_searches.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore + list_phone_numbers.metadata = {'url': '/phoneNumbers'} # type: ignore - def cancel_search( + def get_phone_number( self, - search_id, # type: str + phone_number, # type: str **kwargs # type: Any ): - # type: (...) -> None - """Cancels the search. This means existing numbers in the search will be made available. + # type: (...) -> "models.AcquiredPhoneNumber" + """Gets information about an acquired phone number. - Cancels the search. This means existing numbers in the search will be made available. + Gets information about an acquired phone number. - :param search_id: The search id to be canceled. - :type search_id: str + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :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 + :return: AcquiredPhoneNumber, or the result of cls(response) + :rtype: ~azure.communication.administration.models.AcquiredPhoneNumber :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] 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 + url = self.get_phone_number.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'), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = '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('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def _update_phone_number_initial( + self, + phone_number, # type: str + callback_url=None, # type: Optional[str] + application_id=None, # type: Optional[str] + capabilities=None, # type: Optional["models.Capabilities"] + **kwargs # type: Any + ): + # type: (...) -> "models.AcquiredPhoneNumber" + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _update = models.AcquiredPhoneNumberUpdate(callback_url=callback_url, application_id=application_id, capabilities=capabilities) + api_version = "2020-07-20-preview1" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + + # Construct URL + url = self._update_phone_number_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1300,8 +605,14 @@ def cancel_search( # 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] + body_content = self._serialize.body(_update, 'AcquiredPhoneNumberUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1310,38 +621,108 @@ def cancel_search( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) - cancel_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/cancel'} # type: ignore + return deserialized + _update_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore - def purchase_search( + def begin_update_phone_number( self, - search_id, # type: str + phone_number, # type: str + callback_url=None, # type: Optional[str] + application_id=None, # type: Optional[str] + capabilities=None, # type: Optional["models.Capabilities"] **kwargs # type: Any ): - # type: (...) -> None - """Purchases the phone number search. + # type: (...) -> LROPoller["models.AcquiredPhoneNumber"] + """Update an acquired phone number. - Purchases the phone number search. + Update an acquired phone number. - :param search_id: The search id to be purchased. - :type search_id: str + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :type phone_number: str + :param callback_url: The webhook URL for receiving incoming events. + :type callback_url: str + :param application_id: The application id the number has been assigned to. + :type application_id: str + :param capabilities: The new set of enabled capabilities. + :type capabilities: ~azure.communication.administration.models.Capabilities :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either AcquiredPhoneNumber or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.models.AcquiredPhoneNumber] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumber"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_phone_number_initial( + phone_number=phone_number, + callback_url=callback_url, + application_id=application_id, + capabilities=capabilities, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def _release_phone_number_initial( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> None cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = {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 + url = self._release_phone_number_initial.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -1352,7 +733,7 @@ def purchase_search( # Construct headers header_parameters = {} # type: Dict[str, Any] - request = self._client.post(url, query_parameters, header_parameters) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1361,7 +742,68 @@ def purchase_search( error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) + + _release_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def begin_release_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Releases an acquired phone number. - purchase_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/purchase'} # type: ignore + Releases an acquired phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B. + :type phone_number: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._release_phone_number_initial( + phone_number=phone_number, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_release_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore diff --git a/sdk/communication/azure-communication-administration/samples/phone_number_redesign_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_redesign_sample.py new file mode 100644 index 000000000000..90cef47e8b33 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_redesign_sample.py @@ -0,0 +1,117 @@ +# 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_redesign_sample.py +DESCRIPTION: + This sample demonstrates how seach, purchase, update, release and list phone numbers +USAGE: + python phone_number_redesign_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, + SearchCapabilities, + SearchResult, + Capabilities, + AcquiredPhoneNumberUpdate +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + + +def begin_search_phone_numbers(): + # [START begin_reserve_phone_numbers] + country_code = "US" + search_capabilities = SearchCapabilities( + sms="outbound", + calling="inbound+outbound" + ) + + search_phone_numbers_poller = phone_number_administration_client.begin_search_phone_numbers( + country_code=country_code, + number_type="geographic", + assignment_type="application", + capabilities=search_capabilities, + area_code="425", + quantity=2 + ) + + # [END begin_reserve_phone_numbers] + search_result=search_phone_numbers_poller.result() + print('SearchId: ', search_result.id) + print('Monthly Rate: ', search_result.monthly_rate.value) + for phoneNumber in search_result.phone_numbers: + print('Available Phone Number: ', phoneNumber) + +def begin_purchase_phone_numbers(): + # [START begin_purchase_phone_numbers] + search_id = "SEARCH_ID" + + purchase_phone_numbers_poller = phone_number_administration_client.begin_purchase_phone_numbers( + search_id=search_id + ) + + # [END begin_purchase_phone_numbers] + search_result=purchase_phone_numbers_poller.result() + print('Purchase completed for the search: ', search_result.id) + +def begin_update_phone_number(): + # [START begin_update_phone_number] + phone_number = "PHONE_NUMBER" + + capabilities = Capabilities( + sms="inbound+outbound" + ) + + update_phone_number_poller = phone_number_administration_client.begin_update_phone_number( + phone_number=phone_number, + callback_url = "https://contoso.com/webhooks/phone", + application_id = "1dcb5bde-f5f5-4195-a1c1-43f157688769", + capabilities = capabilities + ) + + # [END begin_update_phone_number] + update_result=update_phone_number_poller.result() + + print("Updated Application Id:" + update_result.application_id) + print("Updated Callback Url:" + update_result.callback_url) + print("Updated SMS:" + update_result.capabilities.sms) + +def begin_release_phone_number(): + # [START begin_release_phone_number] + phone_number = "PHONE_NUMBER" + + release_phone_number_poller = phone_number_administration_client.begin_release_phone_number( + phone_number=phone_number + ) + + # [END begin_release_phone_number] + release_phone_number_poller.result() + print('Release succeeded for phone number: ', phone_number) + +def list_acquired_phone_numbers(): + # [START list_acquired_phone_numbers] + acquired_phone_numbers = phone_number_administration_client.list_acquired_phone_numbers() + + # [END list_acquired_phone_numbers] + print('Displaying all acquired phone numbers') + for acquired_phone_number in acquired_phone_numbers: + print(acquired_phone_number.phone_number) + +if __name__ == '__main__': + begin_search_phone_numbers() + begin_purchase_phone_numbers() + begin_update_phone_number() + begin_release_phone_number() + list_acquired_phone_numbers() 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 bad4556598b3..c422d5ac7135 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: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/257f060be8b60d8468584682aa2d71b1faa5f82c/specification/communication/data-plane/Microsoft.CommunicationServicesAdministration/preview/2020-07-20-preview1/communicationservicesadministration.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/ca264fa5c7c47c556f5e1ea75df04fd2c2e9b89d/specification/communication/data-plane/Microsoft.CommunicationServicesAdministration/preview/2020-11-01-preview3/phonenumbers.json output-folder: ../azure/communication/administration/_phonenumber/_generated namespace: azure.communication.administration license-header: MICROSOFT_MIT_NO_VERSION @@ -19,24 +19,4 @@ no-namespace-folders: true clear-output-folder: true v3: true python: true -``` - -### Rename searchId to reservationId -```yaml -directive: - - from: swagger-document - where: $.definitions.PhoneNumberSearch.properties.searchId - transform: > - $["x-ms-client-name"] = "reservationId"; -``` - -### Rename PhoneNumberSearch to PhoneNumberReservation -```yaml -custom-types-subpackage: models -custom-types: PhoneNumberReservation -required-fields-as-ctor-args: true -directive: - - rename-model: - from: PhoneNumberSearch - to: PhoneNumberReservation ``` \ No newline at end of file