# Azure Communication Rooms client library for Python
This package contains a Python SDK for Azure Communication Services for Rooms.
Read more about Azure Communication Services [here](https://docs.microsoft.com/azure/communication-services/overview)
## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please
refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
## Key concepts
The Azure Communication Rooms package is used to do following:
- Create scheduled meetings
- Create meetings with managed permissions for its participants
## Getting started
### Installating the package
```bash
python -m pip install azure-communication-rooms
```
#### Prequisites
- Python 3.7 or later is required to use this package.
- You need an [Azure subscription][azure_sub] to use this package.
- A deployed Communication Services resource. You can use the [Azure Portal](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up.
### Client Initialization
To initialize the Rooms Client, the connection string can be used to instantiate.
```python
from azure.communication.rooms import RoomsClient
client = RoomsClient.from_connection_string(conn_str='<connection_str>' )
```
## Examples
### Key parameters
- `valid_from`: A datetime object from which room will start existing
- `valid_until`: A datetime object after which room meeting would end
- `participants`: A list of `RoomParticipant`s containing MRI's of invitees to the room as well as optional `ParticipantRole`. If `ParticipantRole` is not specified, then it will be `Attendee` by default.
All the above attributes are optional. The service provides default values of valid_until and
valid_from if they are missing. The default for`valid_from` is current date time and the default for `valid_until` is `valid_from + 180 days`.
- `pstn_dial_out_enabled`: Set this flag to true if, at the time of the call, dial out to a PSTN number is enabled in a particular room. This flag is optional.
### Create a room
To create a room, call the `create_room` function from `RoomsClient`. The `valid_from`, `valid_until`, and `participants` arguments are all optional.
Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To create room with PSTN Dial-Out property, call `create_room` function and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then the default value for `pstn_dial_out_enabled` is false.
```python
from azure.core.exceptions import HttpResponseError
from datetime import datetime, timedelta
from azure.communication.rooms import (
RoomsClient,
RoomParticipant,
ParticipantRole
)
from azure.communication.identity import CommunicationUserIdentifier
from dateutil.relativedelta import relativedelta
client = RoomsClient.from_connection_string(conn_str='<connection_str>')
valid_from = datetime.now()
valid_until = valid_from + relativedelta(months=+1)
participants = []
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 1>")))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 2>"), role=ParticipantRole.CONSUMER))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 3>"), role=ParticipantRole.PRESENTER))
try:
create_room_response = client.create_room(
valid_from=valid_from,
valid_until=valid_until,
participants=participants,
pstn_dial_out_enabled=false
)
except HttpResponseError as ex:
print(ex)
```
### Update a room
The `valid_from` and `valid_until` properties of a created room can be updated by calling the `update_room` function from `RoomsClient`.
Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To update a room with PSTN Dial-Out property, call `update_room` and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then there is no changes to PstnDialOutEnabled property in the room.
```python
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),
pstn_dial_out_enabled=false
)
except HttpResponseError as e:
print('service responds error: {}'.format(e))
```
### Get a room
A created room can be retrieved by calling the `get_room` function from `RoomsClient` and passing in the associated `room_id`.
```python
try:
get_room_response = client.get_room(room_id="id of the room to get")
except HttpResponseError as ex:
print(ex)
```
### List rooms
Retrieve all valid rooms created with an ACS resource by calling the `list_rooms` function from `RoomsClient`.
```python
try:
list_room_response = client.list_rooms()
except HttpResponseError as ex:
print(ex)
```
### Delete a room
To delete a room, call the `delete_room` function from RoomsClient.
```python
try:
client.delete_room(
room_id="id of the room to be deleted")
except HttpResponseError as e:
print('service responds error: {}'.format(e))
```
### Add or update participants in a room
In order to insert new participants or update existing participants, call the `add_or_update_participants` function from RoomsClient.
```python
participants = []
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 1>")))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 2>"), role=ParticipantRole.ATTENDEE))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 3>"), role=ParticipantRole.CONSUMER))
try:
response = client.add_or_update_participants(
room_id="id of the room to be updated",
participants=participants
)
except HttpResponseError as e:
print('service responds error: {}'.format(e))
```
### Remove participants
Remove participants from a room by calling the `remove_participants` function from RoomsClient.
```python
communication_identifiers = [CommunicationUserIdentifier("<ACS User MRI identity 2>")]
try:
remove_participants_response = client.remove_participants(
room_id="id of the room to remove participants",
participants=communication_identifiers
)
except HttpResponseError as ex:
print(ex)
```
### List participants
Retrieve the list of participants for an existing room by referencing the `room_id`:
```python
try:
participants = client.list_participants(room_id="id of the room to list participants")
except HttpResponseError as ex:
print(ex)
```
## Troubleshooting
Rooms operations will throw an exception if the request to the server fails. The Rooms client will raise exceptions defined in [Azure Core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md).
## Next steps
### More sample code
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-rooms/samples) directory for detailed examples of how to use this library to create and manage rooms.
## Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project
## Contributing
This 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, visit https://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 the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact opencode@microsoft.com with any
additional questions or comments.
<!-- LINKS -->
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
[azure_identity_pip]: https://pypi.org/project/azure-identity/
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
[pip]: https://pypi.org/project/pip/
[azure_sub]: https://azure.microsoft.com/free/
Raw data
{
"_id": null,
"home_page": "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-rooms",
"name": "azure-communication-rooms",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "azure, azure sdk",
"author": "Microsoft Corporation",
"author_email": "azpysdkhelp@microsoft.com",
"download_url": "https://files.pythonhosted.org/packages/f1/d5/687680b4a9cb741656f4a43f779d2c31a13b8b213cf764bd8c7b5d451f00/azure-communication-rooms-1.1.0.tar.gz",
"platform": null,
"description": "# Azure Communication Rooms client library for Python\nThis package contains a Python SDK for Azure Communication Services for Rooms.\nRead more about Azure Communication Services [here](https://docs.microsoft.com/azure/communication-services/overview)\n\n## _Disclaimer_\n\n_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please\nrefer to https://github.com/Azure/azure-sdk-for-python/issues/20691_\n\n## Key concepts\n\nThe Azure Communication Rooms package is used to do following:\n- Create scheduled meetings\n- Create meetings with managed permissions for its participants\n## Getting started\n\n### Installating the package\n\n```bash\npython -m pip install azure-communication-rooms\n```\n\n#### Prequisites\n\n- Python 3.7 or later is required to use this package.\n- You need an [Azure subscription][azure_sub] to use this package.\n- A deployed Communication Services resource. You can use the [Azure Portal](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up.\n\n\n### Client Initialization\n\nTo initialize the Rooms Client, the connection string can be used to instantiate.\n\n```python\nfrom azure.communication.rooms import RoomsClient\n\nclient = RoomsClient.from_connection_string(conn_str='<connection_str>' )\n```\n## Examples\n\n### Key parameters\n\n- `valid_from`: A datetime object from which room will start existing\n- `valid_until`: A datetime object after which room meeting would end\n- `participants`: A list of `RoomParticipant`s containing MRI's of invitees to the room as well as optional `ParticipantRole`. If `ParticipantRole` is not specified, then it will be `Attendee` by default.\nAll the above attributes are optional. The service provides default values of valid_until and\nvalid_from if they are missing. The default for`valid_from` is current date time and the default for `valid_until` is `valid_from + 180 days`.\n- `pstn_dial_out_enabled`: Set this flag to true if, at the time of the call, dial out to a PSTN number is enabled in a particular room. This flag is optional.\n\n### Create a room\nTo create a room, call the `create_room` function from `RoomsClient`. The `valid_from`, `valid_until`, and `participants` arguments are all optional.\nStarting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To create room with PSTN Dial-Out property, call `create_room` function and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then the default value for `pstn_dial_out_enabled` is false.\n\n```python\nfrom azure.core.exceptions import HttpResponseError\nfrom datetime import datetime, timedelta\nfrom azure.communication.rooms import (\n RoomsClient,\n RoomParticipant,\n ParticipantRole\n)\nfrom azure.communication.identity import CommunicationUserIdentifier\nfrom dateutil.relativedelta import relativedelta\n\nclient = RoomsClient.from_connection_string(conn_str='<connection_str>')\nvalid_from = datetime.now()\nvalid_until = valid_from + relativedelta(months=+1)\nparticipants = []\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 1>\")))\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 2>\"), role=ParticipantRole.CONSUMER))\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 3>\"), role=ParticipantRole.PRESENTER))\n\ntry:\n create_room_response = client.create_room(\n valid_from=valid_from,\n valid_until=valid_until,\n participants=participants,\n pstn_dial_out_enabled=false\n\n )\nexcept HttpResponseError as ex:\n print(ex)\n```\n### Update a room\nThe `valid_from` and `valid_until` properties of a created room can be updated by calling the `update_room` function from `RoomsClient`.\nStarting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To update a room with PSTN Dial-Out property, call `update_room` and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then there is no changes to PstnDialOutEnabled property in the room.\n\n```python\ntry:\n update_room_response = client.update_room(\n room_id=\"id of the room to be updated\",\n valid_from=datetime.now(),\n valid_until=valid_from + timedelta(weeks=4),\n pstn_dial_out_enabled=false\n )\nexcept HttpResponseError as e:\n print('service responds error: {}'.format(e))\n\n```\n\n### Get a room\nA created room can be retrieved by calling the `get_room` function from `RoomsClient` and passing in the associated `room_id`.\n\n```python\ntry:\n get_room_response = client.get_room(room_id=\"id of the room to get\")\nexcept HttpResponseError as ex:\n print(ex)\n```\n\n### List rooms\nRetrieve all valid rooms created with an ACS resource by calling the `list_rooms` function from `RoomsClient`.\n\n```python\ntry:\n list_room_response = client.list_rooms()\nexcept HttpResponseError as ex:\n print(ex)\n```\n\n### Delete a room\nTo delete a room, call the `delete_room` function from RoomsClient.\n\n```python\ntry:\n client.delete_room(\n room_id=\"id of the room to be deleted\")\nexcept HttpResponseError as e:\n print('service responds error: {}'.format(e))\n\n```\n\n### Add or update participants in a room\nIn order to insert new participants or update existing participants, call the `add_or_update_participants` function from RoomsClient.\n\n```python\nparticipants = []\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 1>\")))\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 2>\"), role=ParticipantRole.ATTENDEE))\nparticipants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier(\"<ACS User MRI identity 3>\"), role=ParticipantRole.CONSUMER))\ntry:\n response = client.add_or_update_participants(\n room_id=\"id of the room to be updated\",\n participants=participants\n )\nexcept HttpResponseError as e:\n print('service responds error: {}'.format(e))\n```\n\n### Remove participants\nRemove participants from a room by calling the `remove_participants` function from RoomsClient.\n\n```python\ncommunication_identifiers = [CommunicationUserIdentifier(\"<ACS User MRI identity 2>\")]\n\ntry:\n remove_participants_response = client.remove_participants(\n room_id=\"id of the room to remove participants\",\n participants=communication_identifiers\n )\nexcept HttpResponseError as ex:\n print(ex)\n```\n### List participants\nRetrieve the list of participants for an existing room by referencing the `room_id`:\n\n```python\ntry:\n participants = client.list_participants(room_id=\"id of the room to list participants\")\nexcept HttpResponseError as ex:\n print(ex)\n```\n## Troubleshooting\n\nRooms operations will throw an exception if the request to the server fails. The Rooms client will raise exceptions defined in [Azure Core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md).\n\n## Next steps\n### More sample code\nPlease take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-rooms/samples) directory for detailed examples of how to use this library to create and manage rooms.\n\n## Provide Feedback\n\nIf you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project\n\n## Contributing\n\nThis project welcomes contributions and suggestions. Most contributions require\nyou to agree to a Contributor License Agreement (CLA) declaring that you have\nthe right to, and actually do, grant us the rights to use your contribution.\nFor details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether\nyou need to provide a CLA and decorate the PR appropriately (e.g., label,\ncomment). Simply follow the instructions provided by the bot. You will only\nneed to do this once across all repos using our CLA.\n\nThis project has adopted the\n[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,\nsee the Code of Conduct FAQ or contact opencode@microsoft.com with any\nadditional questions or comments.\n\n<!-- LINKS -->\n[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/\n[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token\n[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials\n[azure_identity_pip]: https://pypi.org/project/azure-identity/\n[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential\n[pip]: https://pypi.org/project/pip/\n[azure_sub]: https://azure.microsoft.com/free/\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Microsoft Communication Rooms Client Library for Python",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-rooms"
},
"split_keywords": [
"azure",
" azure sdk"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3967b9e82328410c622aef6737341975988a205750a2efc187cec70c3f6c0ae1",
"md5": "ea54a5789105203f7c51cd6d7bd2d5a0",
"sha256": "6646e529c667b14699619488dc3ba7807b63097499f3899139538842f0bbc9b7"
},
"downloads": -1,
"filename": "azure_communication_rooms-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ea54a5789105203f7c51cd6d7bd2d5a0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 65565,
"upload_time": "2024-04-18T03:34:32",
"upload_time_iso_8601": "2024-04-18T03:34:32.392113Z",
"url": "https://files.pythonhosted.org/packages/39/67/b9e82328410c622aef6737341975988a205750a2efc187cec70c3f6c0ae1/azure_communication_rooms-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f1d5687680b4a9cb741656f4a43f779d2c31a13b8b213cf764bd8c7b5d451f00",
"md5": "7ff0122c1422da64002470b5e50bab28",
"sha256": "851616f35a54ea11909f84012db8f95dcd5f2efbcc875ca6830601dace1c231d"
},
"downloads": -1,
"filename": "azure-communication-rooms-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "7ff0122c1422da64002470b5e50bab28",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 62646,
"upload_time": "2024-04-18T03:34:30",
"upload_time_iso_8601": "2024-04-18T03:34:30.539790Z",
"url": "https://files.pythonhosted.org/packages/f1/d5/687680b4a9cb741656f4a43f779d2c31a13b8b213cf764bd8c7b5d451f00/azure-communication-rooms-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-18 03:34:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Azure",
"github_project": "azure-sdk-for-python",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "azure-communication-rooms"
}