Skip to content

Commit 2b7ce35

Browse files
committed
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-python into update_ta_tests
* 'master' of https://github.com/Azure/azure-sdk-for-python: Update get_package_properties.py logic for python 2.7 (#17144) update changelog (#17150) [ServiceBus] 7.1.0 Release update changelog (#17135) [ServiceBus] Object mapping support (#17080) move SetTestPipeline into its own template (#17141) Revise token cache configuration API (#16326) Fix dup cloud error (#17097) Perf tests for monitor exporter (#17067) [Communication] - Phone Number - Redesigned API (#16671) disable retry (#17078) [Key Vault] Add perf tests for certificates, keys, and secrets (#17073) [text analytics] Analyze updates for v5.1.0b6 (#17003) Add any additional claims to AuthenticationRequiredError (#17136) Fix logic in SetTestPipelineVersionInEngCommon (#17138) [Key Vault] Make test resource cleanup script asynchronous (#17032)
2 parents 7758b51 + e14bfb4 commit 2b7ce35

File tree

239 files changed

+7760
-13914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+7760
-13914
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parameters:
2+
PackageName: ''
3+
ServiceDirectory: ''
4+
TestPipeline: false
5+
6+
steps:
7+
- ${{if eq(parameters.TestPipeline, 'true')}}:
8+
- task: PowerShell@2
9+
displayName: Prep template pipeline for release
10+
condition: succeeded()
11+
inputs:
12+
pwsh: true
13+
workingDirectory: $(Build.SourcesDirectory)
14+
filePath: $(Build.SourcesDirectory)/eng/common/scripts/SetTestPipelineVersion.ps1
15+
arguments: '-BuildID $(Build.BuildId) -PackageName ${{ parameters.PackageName }} -ServiceDirectory ${{ parameters.ServiceDirectory }}'

eng/common/scripts/SetTestPipelineVersion.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ param (
99
$ServiceDirectory
1010
)
1111

12-
. common.ps1
12+
. (Join-Path $PSScriptRoot common.ps1)
1313

1414
$latestTags = git tag -l "${PackageName}_*"
1515
$semVars = @()
@@ -28,6 +28,6 @@ $newVersion.PrereleaseNumber = $BuildID
2828

2929
LogDebug "Version to publish [ $($newVersion.ToString()) ]"
3030

31-
SetPackageVersion -PackageName $PackagName `
31+
SetPackageVersion -PackageName $PackageName `
3232
-Version $newVersion `
33-
-ServiceDirectory $ServiceDirectory `
33+
-ServiceDirectory $ServiceDirectory

eng/scripts/Language-Settings.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ $BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=con
88
function Get-AllPackageInfoFromRepo ($serviceDirectory)
99
{
1010
$allPackageProps = @()
11-
$searchPath = Join-Path sdk * * setup.py
11+
$searchPath = "sdk"
1212
if ($serviceDirectory)
1313
{
14-
$searchPath = Join-Path sdk ${serviceDirectory} * setup.py
14+
$searchPath = Join-Path sdk ${serviceDirectory}
1515
}
1616

1717
$allPkgPropLines = $null

eng/scripts/get_package_properties.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
parser.add_argument('-s', '--search_path', required=True, help='The scope of the search')
1212
args = parser.parse_args()
1313

14-
for p in glob.glob(args.search_path, recursive=True):
15-
if os.path.basename(os.path.dirname(p)) != 'azure-mgmt' and os.path.basename(os.path.dirname(p)) != 'azure' and os.path.basename(os.path.dirname(p)) != 'azure-storage':
16-
print(get_package_properties(os.path.dirname(p)))
14+
for root, dirs, files in os.walk(args.search_path):
15+
for filename in files:
16+
if os.path.basename(filename) == "setup.py":
17+
if os.path.basename(root) != 'azure-mgmt' and os.path.basename(root) != 'azure' and os.path.basename(root) != 'azure-storage' and os.path.basename(root) != 'tests':
18+
print(get_package_properties(root))

sdk/communication/azure-communication-phonenumbers/README.md

Lines changed: 63 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -16,153 +16,129 @@ Install the Azure Communication Phone Numbers client library for Python with [pi
1616
pip install azure-communication-phonenumbers
1717
```
1818

19-
# Key concepts
19+
## Key concepts
2020

21-
## CommunicationPhoneNumberClient
2221
### Initializing Phone Numbers Client
2322
```python
24-
# You can find your endpoint and access token from your resource in the Azure Portal
23+
# You can find your connection string from your resource in the Azure Portal
2524
import os
26-
from azure.communication.phonenumbers import PhoneNumbersAdministrationClient
25+
from azure.communication.phonenumbers import PhoneNumbersClient
2726
from azure.identity import DefaultAzureCredential
2827

29-
endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT')
28+
endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
3029

3130
# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have your
3231
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
3332
phone_number_administration_client = PhoneNumbersAdministrationClient(endpoint, DefaultAzureCredential())
3433

3534
```
36-
### Initializing Phone Numbers Client Using Connection String
35+
### Initializing the Client Using Your Connection String
3736
Connection string authentication is also available for Phone Numbers Client.
3837

3938
```python
40-
# You can find your endpoint and access token from your resource in the Azure Portal
39+
# You can find your connection string from your resource in the Azure Portal
4140
import os
42-
from azure.communication.phonenumbers import PhoneNumbersAdministrationClient
41+
from azure.communication.phonenumbers import PhoneNumbersClient
4342

4443
connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
4544
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
4645
```
4746

48-
### Phone plans overview
47+
### Phone Number Types overview
4948

50-
Phone plans come in two types; Geographic and Toll-Free. Geographic phone plans are phone plans associated with a location, whose phone numbers' area codes are associated with the area code of a geographic location. Toll-Free phone plans are phone plans not associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888.
49+
Phone numbers come in two types; Geographic and Toll-Free. Geographic phone numbers are phone numbers associated with a location, whose area codes are associated with the area code of a geographic location. Toll-Free phone numbers are phone numbers with no associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888.
5150

52-
All geographic phone plans within the same country are grouped into a phone plan group with a Geographic phone number type. All Toll-Free phone plans within the same country are grouped into a phone plan group.
51+
### Searching and Purchasing and Releasing numbers
5352

54-
### Reserving and Acquiring numbers
53+
Phone numbers can be searched through the search creation API by providing an area code, quantity of phone numbers, application type, phone number type, and capabilities. The provided quantity of phone numbers will be reserved for ten minutes and can be purchased within this time. If the search is not purchased, the phone numbers will become available to others after ten minutes. If the search is purchased, then the phone numbers are acquired for the Azure resources.
5554

56-
Phone numbers can be reserved through the begin_reserve_phone_numbers API by providing a phone plan id, an area code and quantity of phone numbers. The provided quantity of phone numbers will be reserved for ten minutes. This reservation of phone numbers can either be cancelled or purchased. If the reservation is cancelled, then the phone numbers will become available to others. If the reservation is purchased, then the phone numbers are acquired for the Azure resources.
55+
Phone numbers can also be released using the release API.
5756

58-
### Configuring / Assigning numbers
57+
## Examples
5958

60-
Phone numbers can be assigned to a callback URL via the configure number API. As part of the configuration, you will need an acquired phone number, callback URL and application id.
59+
### Get All Phone Numbers
6160

62-
# Examples
63-
The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including:
64-
65-
## Communication Phone number
66-
### Get Countries
61+
Lists all of your acquired phone numbers
6762

6863
```python
69-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
70-
71-
supported_countries = phone_number_administration_client.list_all_supported_countries()
72-
for supported_country in supported_countries:
73-
print(supported_country)
64+
acquired_phone_numbers = phone_numbers_client.list_acquired_phone_numbers()
65+
acquired_phone_number = acquired_phone_numbers.next()
66+
print(acquired_phone_number.phone_number)
7467
```
7568

76-
### Get Phone Plan Groups
69+
### Get Phone Number
7770

78-
Phone plan groups come in two types, Geographic and Toll-Free.
71+
Gets the information from the specified phone number
7972

8073
```python
81-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
82-
83-
phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups(
84-
country_code='<country code>'
85-
)
86-
for phone_plan_group in phone_plan_groups_response:
87-
print(phone_plan_group)
74+
result = phone_numbers_client.get_phone_number("<phone number>")
75+
print(result.country_code)
76+
print(result.phone_number)
8877
```
8978

90-
### Get Phone Plans
79+
## Long Running Operations
9180

92-
Unlike Toll-Free phone plans, area codes for Geographic Phone Plans are empty. Area codes are found in the Area Codes API.
81+
The Phone Number Client supports a variety of long running operations that allow indefinite polling time to the functions listed down below.
9382

94-
```python
95-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
96-
97-
phone_plans_response = phone_number_administration_client.list_phone_plans(
98-
country_code='<country code>',
99-
phone_plan_group_id='<phone plan group id>'
100-
)
101-
for phone_plan in phone_plans_response:
102-
print(phone_plan)
103-
```
104-
105-
### Get Location Options
83+
### Search for Available Phone Number
10684

107-
For Geographic phone plans, you can query the available geographic locations. The locations options are structured like the geographic hierarchy of a country. For example, the US has states and within each state are cities.
85+
You can search for available phone numbers by providing the capabilities of the phone you want to acquire, the phone number type, the assignment type, and the country code. It's worth mentioning that for the toll-free phone number type, proving the area code is optional.
86+
The result of the search can then be used to purchase the number in the corresponding API.
10887

10988
```python
110-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
111-
112-
location_options_response = phone_number_administration_client.get_phone_plan_location_options(
113-
country_code='<country code>',
114-
phone_plan_group_id='<phone plan group id>',
115-
phone_plan_id='<phone plan id>'
89+
capabilities = PhoneNumberCapabilities(
90+
calling = PhoneNumberCapabilityType.INBOUND,
91+
sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND
92+
)
93+
poller = phone_numbers_client.begin_search_available_phone_numbers(
94+
"US",
95+
PhoneNumberType.TOLL_FREE,
96+
PhoneNumberAssignmentType.APPLICATION,
97+
capabilities,
98+
area_code ="833", # Area code is optional for toll-free numbers
99+
quantity = 2, # Quantity is optional. If not set, default is 1
100+
polling = True
116101
)
117-
print(location_options_response)
102+
search_result = poller.result()
118103
```
119104

120-
### Get Area Codes
105+
### Purchase Phone Numbers
121106

122-
Fetching area codes for geographic phone plans will require the the location options queries set. You must include the chain of geographic locations traversing down the location options object returned by the GetLocationOptions API.
107+
The result of your search can be used to purchase the specificied phone numbers. This can be done by passing the `search_id` from the search response to the purchase phone number API.
123108

124109
```python
125-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
126-
127-
all_area_codes = phone_number_administration_client.get_all_area_codes(
128-
location_type="NotRequired",
129-
country_code='<country code>',
130-
phone_plan_id='<phone plan id>'
110+
purchase_poller = phone_numbers_client.begin_purchase_phone_numbers(
111+
search_result.search_id,
112+
polling=True
131113
)
132-
print(all_area_codes)
133114
```
134115

135-
### Create Reservation
116+
### Release Phone Number
136117

137-
```python
138-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
118+
Releases an acquired phone number.
139119

140-
poller = phone_number_administration_client.begin_reserve_phone_numbers(
141-
area_code='<area code>',
142-
description="testreservation20200014",
143-
display_name="testreservation20200014",
144-
phone_plan_ids=['<phone plan id>'],
145-
quantity=1
120+
```python
121+
poller = self.phone_number_client.begin_release_phone_number(
122+
"<phone number>",
123+
polling = True
146124
)
147125
```
148126

149-
### Get Reservation By Id
150-
```python
151-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
127+
### Updating Phone Number Capabilities
152128

153-
phone_number_reservation_response = phone_number_administration_client.get_reservation_by_id(
154-
reservation_id='<reservation id>'
155-
)
156-
print(reservation_id)
157-
```
129+
Updates the specified phone number capabilities for Calling and SMS to one of:
158130

159-
### Purchase Reservation
131+
- `PhoneNumberCapabilityType.NONE`
132+
- `PhoneNumberCapabilityType.INBOUND`
133+
- `PhoneNumberCapabilityType.OUTBOUND`
134+
- `PhoneNumberCapabilityType.INBOUND_OUTBOUND`
160135

161136
```python
162-
phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str)
163-
164-
poller = phone_number_administration_client.begin_purchase_reservation(
165-
reservation_id='<reservation id to purchase>'
137+
poller = self.phone_number_client.begin_update_phone_number_capabilities(
138+
"<phone number>",
139+
PhoneNumberCapabilityType.OUTBOUND,
140+
PhoneNumberCapabilityType.INBOUND_OUTBOUND,
141+
polling = True
166142
)
167143
```
168144

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

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,27 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
from ._phone_number_administration_client import PhoneNumbersAdministrationClient
8-
from ._polling import ReservePhoneNumberPolling, PurchaseReservationPolling, ReleasePhoneNumberPolling
7+
from ._phone_numbers_client import PhoneNumbersClient
98

109
from ._generated.models import (
1110
AcquiredPhoneNumber,
12-
AcquiredPhoneNumbers,
13-
AreaCodes,
14-
CreateSearchOptions,
15-
CreateSearchResponse,
16-
LocationOptionsQuery,
17-
LocationOptionsResponse,
18-
NumberConfigurationResponse,
19-
NumberUpdateCapabilities,
20-
PhoneNumberCountries,
21-
PhoneNumberEntities,
22-
PhoneNumberRelease,
23-
PhoneNumberReservation,
24-
PhonePlanGroups,
25-
PhonePlansResponse,
26-
PstnConfiguration,
27-
ReleaseResponse,
28-
UpdateNumberCapabilitiesResponse,
29-
UpdatePhoneNumberCapabilitiesResponse
30-
)
31-
32-
from ._shared.models import (
33-
CommunicationUserIdentifier,
34-
PhoneNumberIdentifier,
35-
UnknownIdentifier
11+
PhoneNumberCapabilities,
12+
PhoneNumberCost,
13+
PhoneNumberSearchResult,
14+
BillingFrequency,
15+
PhoneNumberAssignmentType,
16+
PhoneNumberCapabilityType,
17+
PhoneNumberType,
3618
)
3719

3820
__all__ = [
39-
'PhoneNumbersAdministrationClient',
40-
'ReservePhoneNumberPolling',
41-
'PurchaseReservationPolling',
42-
'ReleasePhoneNumberPolling',
43-
44-
# from _phonenumber
4521
'AcquiredPhoneNumber',
46-
'AcquiredPhoneNumbers',
47-
'AreaCodes',
48-
'CreateSearchOptions',
49-
'CreateSearchResponse',
50-
'LocationOptionsQuery',
51-
'LocationOptionsResponse',
52-
'NumberConfigurationResponse',
53-
'NumberUpdateCapabilities',
54-
'PhoneNumberCountries',
55-
'PhoneNumberEntities',
56-
'PhoneNumberRelease',
57-
'PhoneNumberReservation',
58-
'PhonePlanGroups',
59-
'PhonePlansResponse',
60-
'PstnConfiguration',
61-
'ReleaseResponse',
62-
'UpdateNumberCapabilitiesResponse',
63-
'UpdatePhoneNumberCapabilitiesResponse',
64-
65-
# from _shared
66-
'CommunicationUserIdentifier',
67-
'PhoneNumberIdentifier',
68-
'UnknownIdentifier'
22+
'PhoneNumberCapabilities',
23+
'PhoneNumberCost',
24+
'PhoneNumberSearchResult',
25+
'BillingFrequency',
26+
'PhoneNumberAssignmentType',
27+
'PhoneNumberCapabilityType',
28+
'PhoneNumberType',
29+
'PhoneNumbersClient'
6930
]

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._phone_number_administration_service import PhoneNumberAdministrationService
10-
__all__ = ['PhoneNumberAdministrationService']
9+
from ._phone_numbers_client import PhoneNumbersClient
10+
__all__ = ['PhoneNumbersClient']
1111

1212
try:
1313
from ._patch import patch_sdk # type: ignore

0 commit comments

Comments
 (0)