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

Updated ACS Rooms CLI to reference 1.0.0b3 SDK #6322

Merged
merged 5 commits into from
May 28, 2023
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
4 changes: 4 additions & 0 deletions src/communication/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.6
mikehang-msft marked this conversation as resolved.
Show resolved Hide resolved
++++++
* Update Rooms sdk version to 1.0.0b3

1.5.2
++++++
* Email service sdk version set to 1.0.0b1 to satisfy the current contract
Expand Down
16 changes: 8 additions & 8 deletions src/communication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,27 @@ az communication rooms get --room "roomId"
```
##### Create-Room #####
```
az communication rooms create --valid-from "2022-07-14T10:20:30" --valid-to "2022-07-14T10:20:30" --join-policy "CommunicationServiceUsers" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
az communication rooms create --valid-from "2023-03-31T10:20:30" --valid-to "2023-06-31T10:20:30" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
```
##### Update-Room #####
```
az communication rooms update --room "roomId" --valid-from "2022-07-14T10:20:30" --valid-to "2022-07-14T10:20:30" --join-policy "InviteOnly" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
az communication rooms update --room "roomId" --valid-from "2023-03-31T10:20:30" --valid-to "2023-06-31T10:20:30"
```
##### Delete-Room #####
```
az communication rooms delete --room "roomId"
```
##### Get-Room-Participants #####
##### List-Rooms #####
```
az communication rooms participant get --room "roomId"
az communication rooms list
```
##### Add-Room-Participants #####
##### Get-Room-Participants #####
```
az communication rooms participant add --room "roomId" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
az communication rooms participant get --room "roomId"
```
##### Update-Room-Participants #####
##### Add-Or-Update-Room-Participants #####
```
az communication rooms participant update --room "roomId" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
az communication rooms participant add-or-update --room "roomId" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --consumer-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
```
##### Remove-Room-Participants #####
```
Expand Down
29 changes: 13 additions & 16 deletions src/communication/azext_communication/manual/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,6 @@
- name: Create a room with valid-from and valid-until date/times
text: |-
az communication rooms create --valid-from "2022-07-14T10:21" --valid-until "2022-08-14T10:21"
- name: Create a room with InviteOnly join policy
text: |-
az communication rooms create --join-policy "InviteOnly"
- name: Create a room with a list of participants with presenter role
text: |-
az communication rooms create --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
Expand Down Expand Up @@ -464,6 +461,15 @@
az communication rooms delete --room "12345678901234567"
"""

helps['communication rooms list'] = """
type: command
short-summary: "List all active rooms belonging to a current Communication Service resource."
examples:
- name: List all active rooms
text: |-
az communication rooms list
"""

helps['communication rooms participant'] = """
type: group
short-summary: Commands to manage participants of an existing room.
Expand All @@ -478,22 +484,13 @@
az communication rooms participant get --room "12345678901234567"
"""

helps['communication rooms participant add'] = """
type: command
short-summary: "Add participants to a room."
examples:
- name: Add presenter and attendee participants to a room
text: |-
az communication rooms participant add --room "12345678901234567" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
"""

helps['communication rooms participant update'] = """
helps['communication rooms participant add-or-update'] = """
type: command
short-summary: "Replace the participants of a room."
short-summary: "Add or update participants in a room"
examples:
- name: Update room participants
- name: Add a presenter participant to a room and update an attendee participant in a room
text: |-
az communication rooms participant update --room "12345678901234567" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
az communication rooms participant add-or-update --room "12345678901234567" --presenter-participants "8:acs:xxxxxx" "8:acs:xxxxxx" --attendee-participants "8:acs:xxxxxx" "8:acs:xxxxxx"
"""

helps['communication rooms participant remove'] = """
Expand Down
37 changes: 8 additions & 29 deletions src/communication/azext_communication/manual/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,10 @@ def _load_rooms_arguments(self):
with self.argument_context('communication rooms create') as c:
c.argument('valid_from',
help='The timestamp from when the room is open for joining, '
'in in ISO8601 format, ex: 2022-07-14T10:21. Optional.')
'in in ISO8601 format, ex: 2023-03-31T10:21. Optional.')
c.argument('valid_until',
help='The timestamp from when the room can no longer be joined,'
' in ISO8601 format, ex: 2022-07-14T10:21. Optional.')
c.argument('join_policy',
help='The join policy of the room. '
'Can be InviteOnly or CommunicationServiceUsers. Optional.')
' in ISO8601 format, ex: 2023-06-31T10:21. Optional.')
c.argument('presenters', options_list=['--presenter-participants'],
nargs='+', help='Collection of identities to be invited to the room as presenter. Optional.')
c.argument('attendees', options_list=['--attendee-participants'],
Expand All @@ -203,42 +200,24 @@ def _load_rooms_arguments(self):
c.argument('room_id', options_list=['--room'], type=str, help='Room Id')
c.argument('valid_from',
help='The timestamp from when the room is open for joining, in in ISO8601 format, '
'ex: 2022-07-14T10:21. Should be used together with --valid-until. Optional.')
'ex: 2023-03-31T10:21. Should be used together with --valid-until. Optional.')
c.argument('valid_until',
help='The timestamp from when the room can no longer be joined, in ISO8601 format, '
'ex: 2022-07-14T10:21. Should be used together with --valid-from. Optional.')
c.argument('join_policy',
help='The join policy of the room. Can be InviteOnly or CommunicationServiceUsers. Optional.')
c.argument('presenters', options_list=['--presenter-participants'],
nargs='+', help='Collection of identities to be invited to the room as presenter. Optional.')
c.argument('attendees', options_list=['--attendee-participants'],
nargs='+', help='Collection of identities to be invited to the room as attendee. Optional.')
c.argument('consumers', options_list=['--consumer-participants'],
nargs='+', help='Collection of identities to be invited to the room as consumer. Optional.')
'ex: 2023-06-31T10:21. Should be used together with --valid-from. Optional.')

with self.argument_context('communication rooms participant get') as c:
c.argument('room_id', options_list=['--room'],
type=str, help='Room Id')

with self.argument_context('communication rooms participant add') as c:
c.argument('room_id', options_list=['--room'],
type=str, help='Room Id')
c.argument('presenters', options_list=['--presenter-participants'],
nargs='+', help='Collection of identities to be added to the room as presenter. Optional.')
c.argument('attendees', options_list=['--attendee-participants'],
nargs='+', help='Collection of identities to be added to the room as attendee. Optional.')
c.argument('consumers', options_list=['--consumer-participants'],
nargs='+', help='Collection of identities to be added to the room as consumer. Optional.')

with self.argument_context('communication rooms participant update') as c:
with self.argument_context('communication rooms participant add-or-update') as c:
c.argument('room_id', options_list=['--room'],
type=str, help='Room Id')
c.argument('presenters', options_list=['--presenter-participants'],
nargs='+', help='Collection of identities to be added to the room as presenter. Optional.')
nargs='+', help='Collection of identities to be added to the room as presenter.')
c.argument('attendees', options_list=['--attendee-participants'],
nargs='+', help='Collection of identities to be added to the room as attendee. Optional.')
nargs='+', help='Collection of identities to be added to the room as attendee.')
c.argument('consumers', options_list=['--consumer-participants'],
nargs='+', help='Collection of identities to be added to the room as consumer. Optional.')
nargs='+', help='Collection of identities to be added to the room as consumer.')

with self.argument_context('communication rooms participant remove') as c:
c.argument('room_id', options_list=['--room'],
Expand Down
4 changes: 2 additions & 2 deletions src/communication/azext_communication/manual/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ def _load_rooms_command_table(self):
g.communication_custom_command('create', 'communication_rooms_create_room', rooms_arguments)
g.communication_custom_command('update', 'communication_rooms_update_room', rooms_arguments)
g.communication_custom_command('delete', 'communication_rooms_delete_room', rooms_arguments, confirmation=True)
g.communication_custom_command('list', 'communication_rooms_list_rooms', rooms_arguments)

# rooms participant management
with self.command_group('communication rooms participant', client_factory=cf_communication_rooms, is_preview=True) as g:
g.communication_custom_command('get', 'communication_rooms_get_participants', rooms_arguments)
g.communication_custom_command('add', 'communication_rooms_add_participants', rooms_arguments)
g.communication_custom_command('update', 'communication_rooms_update_participants', rooms_arguments)
g.communication_custom_command('add-or-update', 'communication_rooms_add_or_update_participants', rooms_arguments)
g.communication_custom_command('remove', 'communication_rooms_remove_participants', rooms_arguments, confirmation=True)


Expand Down
50 changes: 19 additions & 31 deletions src/communication/azext_communication/manual/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,24 @@ def __to_communication_identifier(participants):

def __to_room_participant(presenters, attendees, consumers):
from azure.communication.identity._shared.models import identifier_from_raw_id
from azure.communication.rooms import RoomParticipant, RoleType
from azure.communication.rooms import RoomParticipant, ParticipantRole

participants = []

if presenters is not None:
identifiers = [identifier_from_raw_id(p) for p in presenters]
participants.extend([RoomParticipant(communication_identifier=i, role=RoleType.PRESENTER) for i in identifiers])
participants.extend([RoomParticipant(communication_identifier=i,
role=ParticipantRole.PRESENTER) for i in identifiers])

if attendees is not None:
identifiers = [identifier_from_raw_id(p) for p in attendees]
participants.extend([RoomParticipant(communication_identifier=i, role=RoleType.ATTENDEE) for i in identifiers])
participants.extend([RoomParticipant(communication_identifier=i,
role=ParticipantRole.ATTENDEE) for i in identifiers])

if consumers is not None:
identifiers = [identifier_from_raw_id(p) for p in consumers]
participants.extend([RoomParticipant(communication_identifier=i, role=RoleType.CONSUMER) for i in identifiers])
participants.extend([RoomParticipant(communication_identifier=i,
role=ParticipantRole.CONSUMER) for i in identifiers])

return participants

Expand All @@ -198,7 +201,6 @@ def communication_rooms_get_room(client, room_id):
def communication_rooms_create_room(client,
valid_from=None,
valid_until=None,
join_policy=None,
presenters=None,
attendees=None,
consumers=None):
Expand All @@ -208,7 +210,6 @@ def communication_rooms_create_room(client,
return client.create_room(
valid_from=valid_from,
valid_until=valid_until,
room_join_policy=join_policy,
participants=room_participants)
except HttpResponseError:
raise
Expand All @@ -227,55 +228,42 @@ def communication_rooms_delete_room(client, room_id):

def communication_rooms_update_room(client, room_id,
valid_from=None,
valid_until=None,
join_policy=None,
presenters=None,
attendees=None,
consumers=None):
valid_until=None):
try:
room_participants = __to_room_participant(presenters, attendees, consumers)

return client.update_room(
room_id=room_id,
valid_from=valid_from,
valid_until=valid_until,
room_join_policy=join_policy,
participants=room_participants)
valid_until=valid_until)
except HttpResponseError:
raise
except Exception as ex:
sys.exit(str(ex))


def communication_rooms_get_participants(client, room_id):
def communication_rooms_list_rooms(client):
try:
return client.get_participants(room_id)
return client.list_rooms()
except HttpResponseError:
raise
except Exception as ex:
sys.exit(str(ex))


def communication_rooms_add_participants(client, room_id,
presenters=None,
attendees=None,
consumers=None):
def communication_rooms_get_participants(client, room_id):
try:
return client.add_participants(
room_id=room_id,
participants=__to_room_participant(presenters, attendees, consumers))
return client.list_participants(room_id)
except HttpResponseError:
raise
except Exception as ex:
sys.exit(str(ex))


def communication_rooms_update_participants(client, room_id,
presenters=None,
attendees=None,
consumers=None):
def communication_rooms_add_or_update_participants(client, room_id,
presenters=None,
attendees=None,
consumers=None):
try:
return client.update_participants(
return client.add_or_update_participants(
room_id=room_id,
participants=__to_room_participant(presenters, attendees, consumers))
except HttpResponseError:
Expand All @@ -288,7 +276,7 @@ def communication_rooms_remove_participants(client, room_id, participants):
try:
return client.remove_participants(
room_id=room_id,
communication_identifiers=__to_communication_identifier(participants))
participants=__to_communication_identifier(participants))
except HttpResponseError:
raise
except Exception as ex:
Expand Down
Loading