Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Azure Communication Services - Phone Number Admin - Implementing long running operations for phone number search " #14208

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from ._communication_identity_client import CommunicationIdentityClient
from ._phone_number_administration_client import PhoneNumberAdministrationClient
from ._polling import PhoneNumberPolling

from ._identity._generated.models import (
CommunicationTokenRequest,
Expand All @@ -17,7 +16,6 @@
AcquiredPhoneNumber,
AcquiredPhoneNumbers,
AreaCodes,
CreateSearchOptions,
CreateSearchResponse,
LocationOptionsQuery,
LocationOptionsResponse,
Expand All @@ -33,7 +31,7 @@
ReleaseResponse,
UpdateNumberCapabilitiesResponse,
UpdatePhoneNumberCapabilitiesResponse,
SearchStatus
CreateSearchOptions
)

from ._shared.models import (
Expand All @@ -45,7 +43,6 @@
__all__ = [
'CommunicationIdentityClient',
'PhoneNumberAdministrationClient',
'PhoneNumberPolling',

# from _identity
'CommunicationTokenRequest',
Expand All @@ -55,23 +52,22 @@
'AcquiredPhoneNumber',
'AcquiredPhoneNumbers',
'AreaCodes',
'CreateSearchOptions',
'CreateSearchResponse',
'LocationOptionsQuery',
'LocationOptionsResponse',
'NumberConfigurationResponse',
'NumberUpdateCapabilities',
'PhoneNumberCountries',
'PhoneNumberEntities',
'PhoneNumberSearch',
'PhoneNumberRelease',
'PhoneNumberSearch',
'PhonePlanGroups',
'PhonePlansResponse',
'PstnConfiguration',
'ReleaseResponse',
'SearchStatus',
'UpdateNumberCapabilitiesResponse',
'UpdatePhoneNumberCapabilitiesResponse',
'CreateSearchOptions',

# from _shared
'CommunicationUser',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
# ------------------------------------
from azure.core.tracing.decorator import distributed_trace
from azure.core.paging import ItemPaged
from azure.core.polling import LROPoller
from ._polling import PhoneNumberPolling

from ._phonenumber._generated._phone_number_administration_service\
import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen

from ._phonenumber._generated.models import (
AcquiredPhoneNumbers,
AreaCodes,
CreateSearchResponse,
LocationOptionsResponse,
NumberConfigurationResponse,
NumberUpdateCapabilities,
Expand All @@ -26,7 +25,6 @@
PhonePlansResponse,
PstnConfiguration,
ReleaseResponse,
SearchStatus,
UpdateNumberCapabilitiesResponse,
UpdatePhoneNumberCapabilitiesResponse
)
Expand Down Expand Up @@ -407,53 +405,21 @@ def get_search_by_id(
)

@distributed_trace
def begin_create_search(
def create_search(
self,
**kwargs # type: Any
):
# type: (...) -> LROPoller
"""Begins creating a phone number search.
Caller must provide either body, or continuation_token keywords to use the method.
If both body and continuation_token are specified, only continuation_token will be used to
restart a poller from a saved state, and keyword body will be ignored.
# type: (...) -> CreateSearchResponse
"""Creates a phone number search.

:keyword azure.communication.administration.CreateSearchOptions body:
A parameter for defining the search options.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch]
An optional parameter for defining the search options.
The default is None.
:rtype: ~azure.communication.administration.CreateSearchResponse
"""
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]

search_polling = PhoneNumberPolling(
is_terminated=lambda status: status in [
SearchStatus.Reserved,
SearchStatus.Expired,
SearchStatus.Success,
SearchStatus.Cancelled,
SearchStatus.Error
]
)

if cont_token is not None:
return LROPoller.from_continuation_token(
polling_method=search_polling,
continuation_token=cont_token,
client=self._phone_number_administration_client.phone_number_administration
)

if "body" not in kwargs:
raise ValueError("Either kwarg 'body' or 'continuation_token' needs to be specified")

create_search_response = self._phone_number_administration_client.phone_number_administration.create_search(
return self._phone_number_administration_client.phone_number_administration.create_search(
**kwargs
)
initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id(
search_id=create_search_response.search_id
)
return LROPoller(client=self._phone_number_administration_client.phone_number_administration,
initial_response=initial_state,
deserialization_callback=None,
polling_method=search_polling)

@distributed_trace
def list_all_searches(
Expand All @@ -474,96 +440,37 @@ def list_all_searches(
)

@distributed_trace
def begin_cancel_search(
def cancel_search(
self,
search_id, # type: str
**kwargs # type: Any
):
# type: (...) -> LROPoller
"""Begins the phone number search cancellation.
Caller must provide either search_id, or continuation_token keywords to use the method.
If both body and continuation_token are specified, only continuation_token will be used to
restart a poller from a saved state, and keyword search_id will be ignored.

:keyword str search_id: The search id to be canceled.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch]
"""
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]

search_polling = PhoneNumberPolling(
is_terminated=lambda status: status in [
SearchStatus.Expired,
SearchStatus.Cancelled,
SearchStatus.Error
]
)

if cont_token is not None:
return LROPoller.from_continuation_token(
polling_method=search_polling,
continuation_token=cont_token,
client=self._phone_number_administration_client.phone_number_administration
)

search_id = kwargs.pop('search_id', None) # type: str
if search_id is None:
raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified")
# type: (...) -> None
"""Cancels the search. This means existing numbers in the search will be made available.

self._phone_number_administration_client.phone_number_administration.cancel_search(
:param search_id: The search id to be canceled.
:type search_id: str
:rtype: None
"""
return self._phone_number_administration_client.phone_number_administration.cancel_search(
search_id,
**kwargs
)
initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id(
search_id=search_id
)
return LROPoller(client=self._phone_number_administration_client.phone_number_administration,
initial_response=initial_state,
deserialization_callback=None,
polling_method=search_polling)

@distributed_trace
def begin_purchase_search(
self,
**kwargs # type: Any
def purchase_search(
self,
search_id, # type: str
**kwargs # type: Any
):
# type: (...) -> LROPoller
"""Begins the phone number search purchase.
Caller must provide either search_id, or continuation_token keywords to use the method.
If both body and continuation_token are specified, only continuation_token will be used to
restart a poller from a saved state, and keyword search_id will be ignored.

:keyword str search_id: The search id to be purchased.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch]
"""
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]

search_polling = PhoneNumberPolling(
is_terminated=lambda status: status in [
SearchStatus.Success,
SearchStatus.Expired,
SearchStatus.Cancelled,
SearchStatus.Error
]
)

if cont_token is not None:
return LROPoller.from_continuation_token(
polling_method=search_polling,
continuation_token=cont_token,
client=self._phone_number_administration_client.phone_number_administration
)

search_id = kwargs.pop('search_id') # type: str
# type: (...) -> None
"""Purchases the phone number search.

self._phone_number_administration_client.phone_number_administration.purchase_search(
:param search_id: The search id to be purchased.
:type search_id: str
:rtype: None
"""
return self._phone_number_administration_client.phone_number_administration.purchase_search(
search_id,
**kwargs
)
initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id(
search_id=search_id
)
return LROPoller(client=self._phone_number_administration_client.phone_number_administration,
initial_response=initial_state,
deserialization_callback=None,
polling_method=search_polling)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from ._communication_identity_client_async import CommunicationIdentityClient
from ._phone_number_administration_client_async import PhoneNumberAdministrationClient
from ._polling_async import PhoneNumberPollingAsync

__all__ = [
'CommunicationIdentityClient',
'PhoneNumberAdministrationClient',
'PhoneNumberPollingAsync'
'PhoneNumberAdministrationClient'
]
Loading