Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f12443e
Added initial acs auth commands
lsundaralingam Jul 27, 2022
f3d67e5
[Communication] add chat command group in preview mode.
mayssamm Aug 3, 2022
8fb1e05
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions
mayssamm Aug 3, 2022
fc5ad18
[Communication] merge from lsundaralingam/azure-cli-extensions.git to…
mayssamm Aug 3, 2022
358374d
[Communication] fix revoke-access-tokens test
mayssamm Aug 3, 2022
1b3266c
[Communication] add tests for chat command group
mayssamm Aug 4, 2022
94a613b
[Communication] fix test name format
mayssamm Aug 4, 2022
1381447
[Communication] remove communication test files from CredScanSuppress…
mayssamm Aug 4, 2022
cf0477b
[Communication] Improve error handling in client factory.
mayssamm Aug 4, 2022
bad876a
[Communication] update readme and history, put commands in preview .
mayssamm Aug 4, 2022
f4ec5cf
[Communication] fix typo in user id argument
mayssamm Aug 4, 2022
9e9249c
[Communication] minor refactor.
mayssamm Aug 4, 2022
2555321
[Communication] update test_communication_scenario
mayssamm Aug 4, 2022
cc82160
[Communication] add the rest of communication identity commands
mayssamm Aug 5, 2022
b16f2f1
[Communication] add test_communication_scenario.yaml back to CredScan…
mayssamm Aug 5, 2022
0b97f9b
[Communication] re-record live tests with python 3.7
mayssamm Aug 5, 2022
7116c35
[Communication] update chat and identity tests
mayssamm Aug 8, 2022
6a5663f
[Communication] Update help and readme for chat and identity, add mor…
mayssamm Aug 9, 2022
e5e0a40
[Communication] Remove python 3.6 to match python sdk and support all…
mayssamm Aug 9, 2022
e6b74f0
[Communication] add dependency to azure-communication-identity >= 1.1.0
mayssamm Aug 9, 2022
b3f49fd
[Communication] address help file style warnings
mayssamm Aug 9, 2022
e2ed2ef
[Communication] add python-3.7 as required
mayssamm Aug 9, 2022
399c43c
Merge branch 'Azure:main' into main
mayssamm Aug 10, 2022
953e2d4
[Communication] update tests, record on python 3.8
mayssamm Aug 10, 2022
2ebba81
[Communicaiton] address PR comments
mayssamm Aug 16, 2022
9d5f920
[Communication] update help and readme
mayssamm Aug 16, 2022
cd30e1e
[Communication] update test recordings
mayssamm Aug 16, 2022
9f050b7
[Communication] update help file
mayssamm Aug 16, 2022
822806d
[Communication] fix typo
mayssamm Aug 16, 2022
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
4 changes: 1 addition & 3 deletions scripts/ci/credscan/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
},
{
"file": [
"src\\communication\\azext_communication\\tests\\latest\\recordings\\test_service_link_to_notification_hub.yaml",
"src\\communication\\azext_communication\\tests\\latest\\recordings\\test_service_regenerate_and_link_key.yaml",
"src\\communication\\azext_communication\\tests\\latest\\test_communication_scenario.py"
"src\\communication\\azext_communication\\tests\\latest\\recordings\\test_communication_scenario.yaml"
],
"_justification": "Dummy resources' tokens left during testing Micorosfot.Communication"
},
Expand Down
10 changes: 10 additions & 0 deletions src/communication/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Release History
===============

1.2.0
++++++
* Add communication chat command group in preview mode.
* Add communication identity command group in preview mode.
* Deprecate 'identity issue-access-token' for 'identity token issue'
* Deprecate 'sms sens-sms' for 'sms send'
* Deprecate 'phonenumbers show-phonenumber' for 'phonenumber show'
* Deprecate 'phonenumbers list-phonenumbers' for 'phonenumber list'


1.1.2
++++++
* Add support for multiple SMS recipients.
Expand Down
86 changes: 81 additions & 5 deletions src/communication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ az extension add --name communication

Then set the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variable with your ACS connection string.

For chat module, set both `AZURE_COMMUNICAITON_ENDPOINT` and `AZURE_COMMUNICATION_ACCESS_TOKEN` environment variables.
You can find your endpoint from your in Azure Portal under your communication resource, and an access token can be created with
```az communication identity token issue --scope chat```.

### Included Features ###

##### Create #####
Expand Down Expand Up @@ -51,22 +55,94 @@ az communication regenerate-key --name "MyCommunicationResource" --key-type "Pri
```
az communication delete --name "MyCommunicationResource" --resource-group "MyResourceGroup"
```
##### Create-User #####
```
az communication identity user create
```
##### Delete-User #####
```
az communication identity user delete --user "8:acs:xxxxxx"
```
##### Issue-Access-Token #####
```
az communication identity issue-access-token --scope chat
az communication identity token issue --scope chat

az communication identity issue-access-token --scope chat voip --userid "8:acs:xxxxxx"
az communication identity token issue --scope chat voip --user "8:acs:xxxxxx"
```
##### Revoke-Access-Tokens #####
```
az communication identity token revoke --user "8:acs:xxxxxx"
```
##### Get-Token-For-Teams-User #####
```
az communication identity token get-for-teams-user --aad-token "MyAzureADToken" --client "MyAzureADAppId" --aad-user "MyTeamsUserId"
```
##### Send-SMS #####
```
az communication sms send-sms --sender "+1833xxxxxxx" \
az communication sms send --sender "+1833xxxxxxx" \
--recipient "+1425xxxxxxx" "+1426xxxxxxx" "+1427xxxxxxx" --message "Hello there!!"
```
##### List-Phonenumbers #####
```
az communication phonenumbers list-phonenumbers
az communication phonenumber list
```
##### Show-Phonenumber #####
```
az communication phonenumbers show-phonenumber --phonenumber "+1833xxxxxxx"
az communication phonenumber show --phonenumber "+1833xxxxxxx"
```
##### List-Threads #####
```
az communication chat thread list --start-time "2022-07-14T10:20:30"
```
##### Create-Thread #####
```
az communication chat thread create --topic "New Topic for Chat!" --idempotency-token "abc187xxxxxx"
```
##### Delete-Thread #####
```
az communication chat thread delete --thread "19:xxxxxx"
```
##### Update Topic #####
```
az communication chat thread update-topic --thread "19:xxxxxx" --topic "New topic!"
```
##### List-Participants #####
```
az communication chat participant list --thread "19:xxxxxx" --skip "5"
```
##### Add-Participant #####
```
az communication chat participant add --thread "19:xxxxxx" --user "8:acs:xxxxxx" --display-name "John Doe" --start-time "2022-06-30T00:00:00"
```
##### Remove-Participant #####
```
az communication chat participant remove --thread "19:xxxxxx" --user "8:acs:xxxxxx"
```
##### Send-Message #####
```
az communication chat message send --thread "19:xxxxxx" --display-name "John Doe" --content "Hello there!" --message-type "text"
```
##### List-Messages #####
```
az communication chat message list --thread "19:xxxxxx" --start-time "2022-07-14T10:20:30"
```
##### Get-Message #####
```
az communication chat message get --thread "19:xxxxxx" --message-id "1xxxxxxxxxxxx"
```
##### Update-Message #####
```
az communication chat message update --thread "19:xxxxxx" --message-id "1xxxxxxxxxxxx" --content "Hello there, again!"
```
##### Delete-Message #####
```
az communication chat message delete --thread "19:xxxxxx" --message-id "1xxxxxxxxxxxx"
```
##### List-Read-Receipts #####
```
az communication chat message receipt list --thread "19:xxxxxx" --skip "5"
```
##### Send-Read-Receipt #####
```
az communication chat message receipt send --thread "19:xxxxxx" --message-id "1xxxxxxxxxxxx"
```
29 changes: 22 additions & 7 deletions src/communication/azext_communication/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,39 @@ def load_arguments(self, command):

class CommunicationCommandGroup(AzCommandGroup):

def communication_custom_command(self, name, method_name, **kwargs):
def communication_custom_command(self, name, method_name, arguments, **kwargs):
command_name = self.custom_command(name, method_name, **kwargs)
self._register_data_plane_account_arguments(command_name)
self._register_data_plane_account_arguments(command_name, arguments)

def _register_data_plane_account_arguments(self, command_name):
def _register_data_plane_account_arguments(self, command_name, arguments):
""" Add parameters required to create a communication client """
from .manual._validators import validate_client_parameters
from .manual._validators import validate_endpoint
from .manual._validators import validate_access_token

command = self.command_loader.command_table.get(command_name, None)

if not command:
return

group_name = 'communication'
command.add_argument('connection_string', '--connection-string', required=False, default=None,
validator=validate_client_parameters, arg_group=group_name,
help='Communication connection string. Environment variable: '
'AZURE_COMMUNICATION_CONNECTION_STRING')
if 'connection_string' in arguments:
command.add_argument('connection_string', '--connection-string', required=False, default=None,
validator=validate_client_parameters, arg_group=group_name,
help='Communication connection string. Environment variable: '
'AZURE_COMMUNICATION_CONNECTION_STRING')

if 'endpoint' in arguments:
command.add_argument('endpoint', '--endpoint', required=False, default=None,
validator=validate_endpoint, arg_group=group_name,
help='Communication endpoint. Environment variable: '
'AZURE_COMMUNICATION_ENDPOINT')

if 'access_token' in arguments:
command.add_argument('access_token', '--access-token', required=False, default=None,
validator=validate_access_token, arg_group=group_name,
help='Communication access token. Environment variable: '
'AZURE_COMMUNICATION_ACCESS_TOKEN')


COMMAND_LOADER_CLS = CommunicationServiceManagementClientCommandsLoader
34 changes: 34 additions & 0 deletions src/communication/azext_communication/manual/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,56 @@


# pylint: disable=unused-argument

from azure.cli.core.azclierror import RequiredArgumentMissingError


def cf_communication_identity(cli_ctx, kwargs):
from azure.communication.identity import CommunicationIdentityClient

connection_string = kwargs.pop('connection_string', None)
if connection_string is None:
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
raise RequiredArgumentMissingError(error_msg)

client = CommunicationIdentityClient.from_connection_string(connection_string)
return client


def cf_communication_sms(cli_ctx, kwargs):
from azure.communication.sms import SmsClient

connection_string = kwargs.pop('connection_string', None)
if connection_string is None:
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
raise RequiredArgumentMissingError(error_msg)

client = SmsClient.from_connection_string(connection_string)
return client


def cf_communication_phonenumbers(cli_ctx, kwargs):
from azure.communication.phonenumbers import PhoneNumbersClient

connection_string = kwargs.pop('connection_string', None)
if connection_string is None:
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
raise RequiredArgumentMissingError(error_msg)

client = PhoneNumbersClient.from_connection_string(connection_string)
return client


def cf_communication_chat(cli_ctx, kwargs):
from azure.communication.chat import ChatClient, CommunicationTokenCredential

endpoint = kwargs.pop('endpoint', None)
if endpoint is None:
raise RequiredArgumentMissingError('Please specify --endpoint, or set AZURE_COMMUNICATION_ENDPOINT.')

token = kwargs.pop('access_token', None)
if token is None:
raise RequiredArgumentMissingError('Please specify --access-token or set AZURE_COMMUNICATION_ACCESS_TOKEN.')

client = ChatClient(endpoint, CommunicationTokenCredential(token))
return client
Loading