Skip to content

Commit 223d948

Browse files
[Communication] - Extract Identity Package out of Administration Package (Azure#16300)
* initial commit: new folder for identity * Added root files to identity package * copy identity client files from admin to new pkg * add autorest generated files * copy samples over * update references in other packages * Added tests to identity package * remove identity code from admin package * update changelog * remove identity code from admin package * update changelog * Removed identity tests from admin package * Update admin readme * add back version.py for wheel generation * Removed user credential test in admin package * update _version.py * remove redundant files * fixed error with init file * minor naming fixes * only expose required shared models * Update chat to reference new identity package * Updated identity test recordings * Added examples to identity README.md * Updated dependencies in identity package * Updated code style to meet pylint requirements * Added identity package to ci file * Updated CHANGELOG version formatting Co-authored-by: Bert Ong <823691+beltr0n@users.noreply.github.com>
1 parent eacd482 commit 223d948

File tree

81 files changed

+1040
-151
lines changed

Some content is hidden

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

81 files changed

+1040
-151
lines changed

sdk/communication/azure-communication-administration/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.0.0b4 (Unreleased)
44

55
### Breaking Changes
6+
- CommunicationIdentityClient is moved to a new package: "azure.communication.identity"
67

78
##### `PhoneNumberAdministrationClient`
89
- `begin_reserve_phone_numbers` now takes `display_name`, `description`, `phone_plan_ids`,

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Azure Communication Administration Package client library for Python
44

5-
Azure Communication Administration client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identities user tokens to be used by other client packages such as chat, calling, sms.
5+
Azure Communication Administration client package is used to administer Phone Numbers.
66

77
# Getting started
88
### Prerequisites
@@ -17,31 +17,6 @@ pip install azure-communication-administration
1717
```
1818

1919
# Key concepts
20-
## CommunicationIdentityClient
21-
`CommunicationIdentityClient` provides operations for:
22-
23-
- Create/delete identities to be used in Azure Communication Services. Those identities can be used to make use of Azure Communication offerings and can be scoped to have limited abilities through token scopes.
24-
25-
- Create/revoke scoped user access tokens to access services such as chat, calling, sms. Tokens are issued for a valid Azure Communication identity and can be revoked at any time.
26-
27-
### Initializing Identity Client
28-
```python
29-
# You can find your endpoint and access token from your resource in the Azure Portal
30-
import os
31-
from azure.communication.administration import CommunicationIdentityClient
32-
from azure.identity import DefaultAzureCredential
33-
34-
connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
35-
endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT')
36-
37-
# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have
38-
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
39-
identity_client_managed_identity = CommunicationIdentityClient.(endpoint, DefaultAzureCredential())
40-
41-
#You can also authenticate using your connection string
42-
identity_client = CommunicationIdentityClient.from_connection_string(connection_str)
43-
44-
```
4520

4621
## CommunicationPhoneNumberClient
4722
### Initializing Phone Number Client
@@ -70,10 +45,6 @@ Phone numbers can be assigned to a callback URL via the configure number API. As
7045
# Examples
7146
The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including:
7247

73-
[Create/delete Azure Communication Service identities][identitysamples]
74-
75-
[Create/revoke scoped user access tokens][identitysamples]
76-
7748
## Communication Phone number
7849
### Get Countries
7950

@@ -179,12 +150,12 @@ poller = phone_number_administration_client.begin_purchase_reservation(
179150
```
180151

181152
# Troubleshooting
182-
The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core].
153+
The Phone Number Administration client will raise exceptions defined in [Azure Core][azure_core].
183154

184155
# Next steps
185156
## More sample code
186157

187-
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/communication/azure-communication-administration/samples) directory for detailed examples of how to use this library to manage identities and tokens.
158+
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/communication/azure-communication-administration/samples) directory for detailed examples of how to use this library.
188159

189160
## Provide Feedback
190161

@@ -201,5 +172,4 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
201172
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
202173

203174
<!-- LINKS -->
204-
[identitysamples]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-administration/samples/identity_samples.py
205175
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
from ._communication_identity_client import CommunicationIdentityClient
87
from ._phone_number_administration_client import PhoneNumberAdministrationClient
98
from ._polling import ReservePhoneNumberPolling, PurchaseReservationPolling, ReleasePhoneNumberPolling
109

11-
from ._identity._generated.models import (
12-
CommunicationTokenRequest,
13-
CommunicationIdentityToken
14-
)
15-
1610
from ._phonenumber._generated.models import (
1711
AcquiredPhoneNumber,
1812
AcquiredPhoneNumbers,
@@ -42,16 +36,11 @@
4236
)
4337

4438
__all__ = [
45-
'CommunicationIdentityClient',
4639
'PhoneNumberAdministrationClient',
4740
'ReservePhoneNumberPolling',
4841
'PurchaseReservationPolling',
4942
'ReleasePhoneNumberPolling',
5043

51-
# from _identity
52-
'CommunicationTokenRequest',
53-
'CommunicationIdentityToken',
54-
5544
# from _phonenumber
5645
'AcquiredPhoneNumber',
5746
'AcquiredPhoneNumbers',

sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py

Whitespace-only changes.

sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from ._communication_identity_client_async import CommunicationIdentityClient
21
from ._phone_number_administration_client_async import PhoneNumberAdministrationClient
32
from ._polling_async import ReservePhoneNumberPollingAsync, \
43
PurchaseReservationPollingAsync, \
54
ReleasePhoneNumberPollingAsync
65

76
__all__ = [
8-
'CommunicationIdentityClient',
97
'PhoneNumberAdministrationClient',
108
'ReservePhoneNumberPollingAsync',
119
'PurchaseReservationPollingAsync',

sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (c) Microsoft Corporation.
55
# Licensed under the MIT License.
66
# ------------------------------------
7-
from typing import Dict, List
7+
from typing import Dict
88

99
from azure.communication.administration._phonenumber._generated.models import ReleaseStatus, CreateSearchOptions
1010
from azure.core.async_paging import AsyncItemPaged

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ pip install --pre azure-communication-chat
2222

2323
## User Access Tokens
2424

25-
User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. You can generate these tokens with azure.communication.administration module, and then use them to initialize the Communication Services SDKs. Example of using azure.communication.administration:
25+
User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. You can generate these tokens with azure.communication.identity module, and then use them to initialize the Communication Services SDKs. Example of using azure.communication.identity:
2626

2727
```bash
28-
pip install --pre azure-communication-administration
28+
pip install --pre azure-communication-identity
2929
```
3030

3131
```python
32-
from azure.communication.administration import CommunicationIdentityClient
32+
from azure.communication.identity import CommunicationIdentityClient
3333
identity_client = CommunicationIdentityClient.from_connection_string("<connection string of your Communication service>")
3434
user = identity_client.create_user()
3535
tokenresponse = identity_client.issue_token(user, scopes=["chat"])
@@ -374,7 +374,7 @@ to create a resource, then set some Environment Variables
374374
set AZURE_COMMUNICATION_SERVICE_ENDPOINT="https://<RESOURCE_NAME>.communcationservices.azure.com"
375375
set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING="<connection string of your Communication service>"
376376

377-
pip install azure-communication-administration
377+
pip install azure-communication-identity
378378

379379
python samples\chat_client_sample.py
380380
python samples\chat_client_sample_async.py
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-e ../../../tools/azure-devtools
22
-e ../../../tools/azure-sdk-tools
33
../azure-communication-nspkg
4-
-e ../azure-communication-administration
5-
aiohttp>=3.0; python_version >= '3.5'
4+
-e ../azure-communication-identity
5+
aiohttp>=3.0; python_version >= '3.5'

sdk/communication/azure-communication-chat/samples/chat_client_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
class ChatClientSamples(object):
30-
from azure.communication.administration import CommunicationIdentityClient
30+
from azure.communication.identity import CommunicationIdentityClient
3131
connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
3232
if not connection_string:
3333
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")

sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
class ChatClientSamplesAsync(object):
30-
from azure.communication.administration import CommunicationIdentityClient
30+
from azure.communication.identity import CommunicationIdentityClient
3131
connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
3232
if not connection_string:
3333
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")

0 commit comments

Comments
 (0)