Skip to content

Commit 9b08ce0

Browse files
authored
[Communication] - azure-communication-phonenumbers - Update default polling interval value (Azure#27600)
* Update default polling interval value when searching phone numbers * Update polling interval for purchase and update * Update polling interval for phone number release * Add readability regarding polling interval * Update polling interval for async client
1 parent bacc704 commit 9b08ce0

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from ._version import SDK_MONIKER
1414
from ._api_versions import DEFAULT_VERSION
1515

16+
_DEFAULT_POLLING_INTERVAL_IN_SECONDS = 2
17+
1618
if TYPE_CHECKING:
1719
from typing import Any
1820
from azure.core.credentials import TokenCredential
@@ -91,12 +93,14 @@ def begin_purchase_phone_numbers(
9193
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
9294
False for no polling, or your own initialized polling object for a personal polling strategy.
9395
:paramtype polling: bool or ~azure.core.polling.PollingMethod
94-
:keyword int polling_interval: Default waiting time between two polls
96+
:keyword int polling_interval: Default waiting time (seconds) between two polls
9597
for LRO operations if no Retry-After header is present.
9698
:rtype: ~azure.core.polling.LROPoller[None]
9799
"""
100+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
98101
return self._phone_number_client.phone_numbers.begin_purchase_phone_numbers(
99102
search_id,
103+
polling_interval=polling_interval,
100104
**kwargs
101105
)
102106

@@ -115,12 +119,14 @@ def begin_release_phone_number(
115119
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
116120
False for no polling, or your own initialized polling object for a personal polling strategy.
117121
:paramtype polling: bool or ~azure.core.polling.PollingMethod
118-
:keyword int polling_interval: Default waiting time between two polls
122+
:keyword int polling_interval: Default waiting time (seconds) between two polls
119123
for LRO operations if no Retry-After header is present.
120124
:rtype: ~azure.core.polling.LROPoller[None]
121125
"""
126+
polling_interval = kwargs.pop("polling_interval", _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
122127
return self._phone_number_client.phone_numbers.begin_release_phone_number(
123128
phone_number,
129+
polling_interval=polling_interval,
124130
**kwargs
125131
)
126132

@@ -155,7 +161,7 @@ def begin_search_available_phone_numbers(
155161
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
156162
False for no polling, or your own initialized polling object for a personal polling strategy.
157163
:paramtype polling: bool or ~azure.core.polling.PollingMethod
158-
:keyword int polling_interval: Default waiting time between two polls
164+
:keyword int polling_interval: Default waiting time (seconds) between two polls
159165
for LRO operations if no Retry-After header is present.
160166
:rtype: ~azure.core.polling.LROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult]
161167
"""
@@ -166,9 +172,11 @@ def begin_search_available_phone_numbers(
166172
quantity=kwargs.pop('quantity', None),
167173
area_code=kwargs.pop('area_code', None)
168174
)
175+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
169176
return self._phone_number_client.phone_numbers.begin_search_available_phone_numbers(
170177
country_code,
171178
search_request,
179+
polling_interval=polling_interval,
172180
**kwargs
173181
)
174182
@distributed_trace
@@ -193,14 +201,16 @@ def begin_update_phone_number_capabilities(
193201
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
194202
False for no polling, or your own initialized polling object for a personal polling strategy.
195203
:paramtype polling: bool or ~azure.core.polling.PollingMethod
196-
:keyword int polling_interval: Default waiting time between two polls
204+
:keyword int polling_interval: Default waiting time (seconds) between two polls
197205
for LRO operations if no Retry-After header is present.
198206
:rtype: ~azure.core.polling.LROPoller[~azure.communication.phonenumbers.models.PurchasedPhoneNumber]
199207
"""
208+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
200209
poller = self._phone_number_client.phone_numbers.begin_update_capabilities(
201210
phone_number,
202211
calling=calling,
203212
sms=sms,
213+
polling_interval=polling_interval,
204214
**kwargs
205215
)
206216

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from .._version import SDK_MONIKER
1616
from .._api_versions import DEFAULT_VERSION
1717

18+
_DEFAULT_POLLING_INTERVAL_IN_SECONDS = 2
19+
1820
if TYPE_CHECKING:
1921
from typing import Any
2022
from azure.core.credentials_async import AsyncTokenCredential
@@ -92,12 +94,14 @@ async def begin_purchase_phone_numbers(
9294
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
9395
False for no polling, or your own initialized polling object for a personal polling strategy.
9496
:paramtype polling: bool or ~azure.core.polling.PollingMethod
95-
:keyword int polling_interval: Default waiting time between two polls
97+
:keyword int polling_interval: Default waiting time (seconds) between two polls
9698
for LRO operations if no Retry-After header is present.
9799
:rtype: ~azure.core.polling.AsyncLROPoller[None]
98100
"""
101+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
99102
return await self._phone_number_client.phone_numbers.begin_purchase_phone_numbers(
100103
search_id,
104+
polling_interval=polling_interval,
101105
**kwargs
102106
)
103107

@@ -116,12 +120,14 @@ async def begin_release_phone_number(
116120
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
117121
False for no polling, or your own initialized polling object for a personal polling strategy.
118122
:paramtype polling: bool or ~azure.core.polling.PollingMethod
119-
:keyword int polling_interval: Default waiting time between two polls
123+
:keyword int polling_interval: Default waiting time (seconds) between two polls
120124
for LRO operations if no Retry-After header is present.
121125
:rtype: ~azure.core.polling.AsyncLROPoller[None]
122126
"""
127+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
123128
return await self._phone_number_client.phone_numbers.begin_release_phone_number(
124129
phone_number,
130+
polling_interval=polling_interval,
125131
**kwargs
126132
)
127133

@@ -156,7 +162,7 @@ async def begin_search_available_phone_numbers(
156162
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
157163
False for no polling, or your own initialized polling object for a personal polling strategy.
158164
:paramtype polling: bool or ~azure.core.polling.PollingMethod
159-
:keyword int polling_interval: Default waiting time between two polls
165+
:keyword int polling_interval: Default waiting time (seconds) between two polls
160166
for LRO operations if no Retry-After header is present.
161167
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult]
162168
"""
@@ -167,9 +173,11 @@ async def begin_search_available_phone_numbers(
167173
quantity=kwargs.pop('quantity', None),
168174
area_code=kwargs.pop('area_code', None)
169175
)
176+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
170177
return await self._phone_number_client.phone_numbers.begin_search_available_phone_numbers(
171178
country_code,
172179
search_request,
180+
polling_interval=polling_interval,
173181
**kwargs
174182
)
175183

@@ -195,14 +203,16 @@ async def begin_update_phone_number_capabilities(
195203
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
196204
False for no polling, or your own initialized polling object for a personal polling strategy.
197205
:paramtype polling: bool or ~azure.core.polling.PollingMethod
198-
:keyword int polling_interval: Default waiting time between two polls
206+
:keyword int polling_interval: Default waiting time (seconds) between two polls
199207
for LRO operations if no Retry-After header is present.
200208
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.phonenumbers.models.PurchasedPhoneNumber]
201209
"""
210+
polling_interval = kwargs.pop('polling_interval', _DEFAULT_POLLING_INTERVAL_IN_SECONDS)
202211
return await self._phone_number_client.phone_numbers.begin_update_capabilities(
203212
phone_number,
204213
calling,
205214
sms,
215+
polling_interval=polling_interval,
206216
**kwargs
207217
)
208218

0 commit comments

Comments
 (0)