Python용 Azure Communication Rooms 클라이언트 라이브러리 - 버전 1.0.0

이 패키지에는 룸용 Azure Communication Services Python SDK가 포함되어 있습니다. Azure Communication Services 대한 자세한 내용은 여기를 참조하세요.

고지 사항

Python 2.7에 대한 Azure SDK Python 패키지 지원은 2022년 1월 1일에 종료되었습니다. 자세한 내용과 질문은 다음을 참조하세요. https://github.com/Azure/azure-sdk-for-python/issues/20691

주요 개념

Azure Communication Rooms 패키지는 다음을 수행하는 데 사용됩니다.

  • 예약된 모임 만들기
  • 참가자에 대한 관리 권한으로 모임 만들기

시작

패키지 설치

python -m pip install azure-communication-rooms

필수 조건

  • 이 패키지를 사용하려면 Python 3.7 이상이 필요합니다.
  • 이 패키지를 사용하려면 Azure 구독 이 필요합니다.
  • 배포된 Communication Services 리소스. Azure Portal 또는 Azure PowerShell 사용하여 설정할 수 있습니다.

클라이언트 초기화

룸 클라이언트를 초기화하기 위해 연결 문자열을 사용하여 인스턴스화할 수 있습니다.

from azure.communication.rooms import RoomsClient

client = RoomsClient.from_connection_string(conn_str='<connection_str>' )

예제

키 매개 변수

  • valid_from: 회의실이 기존 공간을 시작하는 datetime 개체입니다.
  • valid_until: 회의실 모임이 종료된 날짜/시간 개체
  • participants: 회의실에 초대된 MRI와 선택적 ParticipantRole를 포함하는 의 목록RoomParticipant입니다. 가 지정되지 않은 경우 ParticipantRole 기본적으로 지정됩니다 Attendee . 위의 모든 특성은 선택 사항입니다. 서비스는 누락된 경우 valid_until 및 valid_from 기본값을 제공합니다. 의valid_from 기본값은 현재 날짜 시간이며 의 기본값 valid_until 은 입니다 valid_from + 180 days.

회의실 만들기

회의실을 만들려면 에서 RoomsClient함수를 create_room 호출합니다. , valid_untilparticipants 인수는 valid_from모두 선택 사항입니다.

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

client = 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
    )
except HttpResponseError as ex:
    print(ex)

회의실 업데이트

만든 회의실의 및 valid_until 속성은 valid_from 에서 RoomsClient함수를 update_room 호출하여 업데이트할 수 있습니다.

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)
    )
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

회의실 가져오기

만든 회의실은 에서 RoomsClient 함수를 호출하고 연결된 room_idget_room 전달하여 검색할 수 있습니다.

try:
    get_room_response = client.get_room(room_id="id of the room to get")
except HttpResponseError as ex:
    print(ex)

회의실 나열

에서 함수를 호출하여 ACS 리소스로 만든 모든 유효한 회의실을 list_rooms 검색 RoomsClient합니다.

try:
    list_room_response = client.list_rooms()
except HttpResponseError as ex:
    print(ex)

회의실 삭제

회의실을 삭제하려면 RoomsClient에서 함수를 delete_room 호출합니다.

try:
    client.delete_room(
        room_id="id of the room to be deleted")
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

회의실에서 참가자 추가 또는 업데이트

새 참가자를 삽입하거나 기존 참가자를 업데이트하려면 RoomsClient에서 함수를 add_or_update_participants 호출합니다.

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
    )
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

참가자 제거

RoomsClient에서 함수를 호출하여 회의실에서 참가자를 remove_participants 제거합니다.

communication_identifiers = [CommunicationUserIdentifier("<ACS User MRI identity 2>")]

try:
    remove_participants_response = client.remove_participants(
        room_id=room_id,
        participants=communication_identifiers
    )
except HttpResponseError as ex:
    print(ex)

참가자 리스트

를 참조하여 기존 회의실의 참가자 목록을 검색합니다 room_id.

try:
    participants = self.rooms_client.list_participants(room_id)
except HttpResponseError as ex:
    print(ex)

문제 해결

서버에 대한 요청이 실패하면 룸 작업이 예외를 throw합니다. 룸 클라이언트는 Azure Core에 정의된 예외를 발생합니다.

다음 단계

추가 샘플 코드

이 라이브러리를 사용하여 회의실을 만들고 관리하는 방법에 대한 자세한 예제는 샘플 디렉터리를 참조하세요.

피드백 제공

버그가 발생하거나 제안이 있는 경우 프로젝트의 문제 섹션에 문제를 제출하세요.

참여

이 프로젝트에 대한 기여와 제안을 환영합니다. 대부분의 경우 기여하려면 권한을 부여하며 실제로 기여를 사용할 권한을 당사에 부여한다고 선언하는 CLA(기여자 라이선스 계약)에 동의해야 합니다. 자세한 내용은 https://cla.microsoft.com 을 참조하세요.

끌어오기 요청을 제출하면 CLA-bot은 CLA를 제공하고 PR을 적절하게 데코레이팅해야 하는지 여부를 자동으로 결정합니다(예: 레이블, 설명). 봇에서 제공하는 지침을 따르기만 하면 됩니다. 이 작업은 CLA를 사용하여 모든 리포지토리에서 한 번만 수행하면 됩니다.

이 프로젝트에는 Microsoft Open Source Code of Conduct(Microsoft 오픈 소스 준수 사항)가 적용됩니다. 자세한 내용은 준수 사항 FAQ를 참조하거나 opencode@microsoft.com에 추가 질문 또는 의견을 알려주세요.