Package: azure-communication-rooms
Azure Communication Rooms client library for PythonThis package contains a Python SDK for Azure Communication Services for Rooms.
Read more about Azure Communication ServiceshereDisclaimerAzure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please
refer tohttps://github.com/Azure/azure-sdk-for-python/issues/20691Key conceptsThe Azure Communication Rooms package is used to do following:Create scheduled meetingsCreate meetings with managed permissions for its participantsGetting startedInstallating the packagepython-mpipinstallazure-communication-roomsPrequisitesPython 3.7 or later is required to use this package.You need anAzure subscriptionto use this package.A deployed Communication Services resource. You can use theAzure Portalor theAzure PowerShellto set it up.Client InitializationTo initialize the Rooms Client, the connection string can be used to instantiate.fromazure.communication.roomsimportRoomsClientclient=RoomsClient.from_connection_string(conn_str='<connection_str>')ExamplesKey parametersvalid_from: A datetime object from which room will start existingvalid_until: A datetime object after which room meeting would endparticipants: A list ofRoomParticipants containing MRI's of invitees to the room as well as optionalParticipantRole. IfParticipantRoleis not specified, then it will beAttendeeby default.
All the above attributes are optional. The service provides default values of valid_until and
valid_from if they are missing. The default forvalid_fromis current date time and the default forvalid_untilisvalid_from + 180 days.Create a roomTo create a room, call thecreate_roomfunction fromRoomsClient. Thevalid_from,valid_until, andparticipantsarguments are all optional.fromazure.core.exceptionsimportHttpResponseErrorfromdatetimeimportdatetime,timedeltafromazure.communication.roomsimport(RoomsClient,RoomParticipant,ParticipantRole)fromazure.communication.identityimportCommunicationUserIdentifierclient=RoomsClient.from_connection_string(conn_str='<connection_str>')valid_from=datetime.now()valid_until=valid_from+relativedelta(months=+1)participants=[]participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 1>")))participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 2>"),ParticipantRole.CONSUMER))participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 3>"),ParticipantRole.PRESENTER))try:create_room_response=client.create_room(valid_from=valid_from,valid_until=valid_until,participants=participants)exceptHttpResponseErrorasex:print(ex)Update a roomThevalid_fromandvalid_untilproperties of a created room can be updated by calling theupdate_roomfunction fromRoomsClient.try:update_room_response=client.update_room(room_id="id of the room to be updated",valid_from=datetime.now(),valid_until=valid_from+timedelta(weeks=4))exceptHttpResponseErrorase:print('service responds error:{}'.format(e))Get a roomA created room can be retrieved by calling theget_roomfunction fromRoomsClientand passing in the associatedroom_id.try:get_room_response=client.get_room(room_id="id of the room to get")exceptHttpResponseErrorasex:print(ex)List roomsRetrieve all valid rooms created with an ACS resource by calling thelist_roomsfunction fromRoomsClient.try:list_room_response=client.list_rooms()exceptHttpResponseErrorasex:print(ex)Delete a roomTo delete a room, call thedelete_roomfunction from RoomsClient.try:client.delete_room(room_id="id of the room to be deleted")exceptHttpResponseErrorase:print('service responds error:{}'.format(e))Add or update participants in a roomIn order to insert new participants or update existing participants, call theadd_or_update_participantsfunction from RoomsClient.participants=[]participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 1>")))participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 2>"),ParticipantRole.ATTENDEE))participants.append(RoomParticipant(CommunicationUserIdentifier("<ACS User MRI identity 3>"),ParticipantRole.CONSUMER))try:response=client.add_or_update_participants(room_id="id of the room to be updated",participants=participants)exceptHttpResponseErrorase:print('service responds error:{}'.format(e))Remove participantsRemove participants from a room by calling theremove_participantsfunction from RoomsClient.communication_identifiers=[CommunicationUserIdentifier("<ACS User MRI identity 2>")]try:remove_participants_response=client.remove_participants(room_id=room_id,participants=communication_identifiers)exceptHttpResponseErrorasex:print(ex)List participantsRetrieve the list of participants for an existing room by referencing theroom_id:try:participants=self.rooms_client.list_participants(room_id)exceptHttpResponseErrorasex:print(ex)TroubleshootingRooms operations will throw an exception if the request to the server fails. The Rooms client will raise exceptions defined inAzure Core.Next stepsMore sample codePlease take a look at thesamplesdirectory for detailed examples of how to use this library to create and manage rooms.Provide FeedbackIf you encounter any bugs or have suggestions, please file an issue in theIssuessection of the projectContributingThis project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visithttps://cla.microsoft.com.When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.This project has adopted theMicrosoft Open Source Code of Conduct. For more information,
see the Code of Conduct FAQ or contactopencode@microsoft.comwith any
additional questions or comments.