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

add get_meeting_info to TeamsInfo #1704

Merged
merged 4 commits into from
Jun 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions libraries/botbuilder-core/botbuilder/core/teams/teams_info.py
Expand Up @@ -13,6 +13,7 @@
from botbuilder.core.turn_context import Activity, TurnContext
from botbuilder.schema.teams import (
ChannelInfo,
MeetingInfo,
TeamDetails,
TeamsChannelData,
TeamsChannelAccount,
Expand Down Expand Up @@ -225,6 +226,24 @@ async def get_meeting_participant(
meeting_id, participant_id, tenant_id
)

@staticmethod
async def get_meeting_info(
turn_context: TurnContext, meeting_id: str = None
) -> MeetingInfo:
meeting_id = (
meeting_id
if meeting_id
else teams_get_meeting_info(turn_context.activity).id
)
if meeting_id is None:
raise TypeError(
"TeamsInfo._get_meeting_participant: method requires a meeting_id or "
"TurnContext that contains a meeting id"
)

connector_client = await TeamsInfo.get_teams_connector_client(turn_context)
return connector_client.teams.fetch_meeting(meeting_id)

@staticmethod
async def get_teams_connector_client(
turn_context: TurnContext,
Expand Down
16 changes: 16 additions & 0 deletions libraries/botbuilder-core/tests/teams/test_teams_info.py
Expand Up @@ -218,6 +218,22 @@ async def test_get_participant(self):
handler = TeamsActivityHandler()
await handler.on_turn(turn_context)

async def test_get_meeting_info(self):
adapter = SimpleAdapterWithCreateConversation()

activity = Activity(
type="message",
text="Test-get_meeting_info",
channel_id=Channels.ms_teams,
from_property=ChannelAccount(aad_object_id="participantId-1"),
channel_data={"meeting": {"id": "meetingId-1"}},
service_url="https://test.coffee",
)

turn_context = TurnContext(adapter, activity)
handler = TeamsActivityHandler()
await handler.on_turn(turn_context)


class TestTeamsActivityHandler(TeamsActivityHandler):
async def on_turn(self, turn_context: TurnContext):
Expand Down
Expand Up @@ -9,6 +9,8 @@
from ._models_py3 import FileDownloadInfo
from ._models_py3 import FileInfoCard
from ._models_py3 import FileUploadInfo
from ._models_py3 import MeetingDetails
from ._models_py3 import MeetingInfo
from ._models_py3 import MessageActionsPayload
from ._models_py3 import MessageActionsPayloadApp
from ._models_py3 import MessageActionsPayloadAttachment
Expand Down Expand Up @@ -83,6 +85,8 @@
"FileDownloadInfo",
"FileInfoCard",
"FileUploadInfo",
"MeetingDetails",
"MeetingInfo",
"MessageActionsPayload",
"MessageActionsPayloadApp",
"MessageActionsPayloadAttachment",
Expand Down
Expand Up @@ -2370,3 +2370,85 @@ def __init__(self, *, value=None, **kwargs) -> None:

def _custom_init(self):
return


class MeetingDetails(Model):
"""Specific details of a Teams meeting.

:param id: The meeting's Id, encoded as a BASE64 string.
:type id: str
:param ms_graph_resource_id: The MsGraphResourceId, used specifically for MS Graph API calls.
:type ms_graph_resource_id: str
:param scheduled_start_time: The meeting's scheduled start time, in UTC.
:type scheduled_start_time: str
:param scheduled_end_time: The meeting's scheduled end time, in UTC.
:type scheduled_end_time: str
:param join_url: The URL used to join the meeting.
:type join_url: str
:param title: The title of the meeting.
:type title: str
:param type: The meeting's type.
:type type: str
"""

_attribute_map = {
"id": {"key": "uniqueId", "type": "str"},
"ms_graph_resource_id": {"key": "msGraphResourceId", "type": "str"},
"scheduled_start_time": {"key": "scheduledStartTime", "type": "str"},
"scheduled_end_time": {"key": "scheduledEndTime", "type": "str"},
tracyboehrer marked this conversation as resolved.
Show resolved Hide resolved
"join_url": {"key": "joinUrl", "type": "str"},
"title": {"key": "title", "type": "str"},
"type": {"key": "type", "type": "str"},
}

def __init__(
self,
*,
id: str = None,
ms_graph_resource_id: str = None,
scheduled_start_time: str = None,
scheduled_end_time: str = None,
join_url: str = None,
title: str = None,
type: str = None,
**kwargs
) -> None:
super(MeetingDetails, self).__init__(**kwargs)
self.id = id
self.ms_graph_resource_id = ms_graph_resource_id
self.scheduled_start_time = scheduled_start_time
self.scheduled_end_time = scheduled_end_time
self.join_url = join_url
self.title = title
self.type = type


class MeetingInfo(Model):
"""General information about a Teams meeting.

:param details: The specific details of a Teams meeting.
:type details: ~botframework.connector.teams.models.MeetingDetails
:param conversation: The Conversation Account for the meeting.
:type conversation: ~botbuilder.schema.models.ConversationAccount
:param organizer: The meeting's scheduled start time, in UTC.
:type organizer: ~botbuilder.schema.models.TeamsChannelAccount
"""

_attribute_map = {
"details": {"key": "details", "type": "object"},
"conversation": {"key": "conversation", "type": "object"},
"organizer": {"key": "organizer", "type": "object"},
}

def __init__(
self,
*,
details: MeetingDetails = None,
conversation: ConversationAccount = None,
organizer: TeamsChannelAccount = None,
**kwargs
) -> None:
super(MeetingInfo, self).__init__(**kwargs)
self.details = details
self.conversation = conversation
self.organizer = organizer
Expand Up @@ -212,3 +212,58 @@ def fetch_participant(
fetch_participant.metadata = {
"url": "/v1/meetings/{meetingId}/participants/{participantId}?tenantId={tenantId}"
}

def fetch_meeting(
self, meeting_id: str, custom_headers=None, raw=False, **operation_config
):
"""Fetch meeting information.

:param meeting_id: Meeting Id, encoded as a BASE64 string.
:type meeting_id: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: MeetingInfo or ClientRawResponse if raw=true
:rtype: ~botframework.connector.teams.models.MeetingInfo or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""

# Construct URL
url = self.fetch_participant.metadata["url"]
path_format_arguments = {
"meetingId": self._serialize.url("meeting_id", meeting_id, "str")
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}

# Construct headers
header_parameters = {}
header_parameters["Accept"] = "application/json"
if custom_headers:
header_parameters.update(custom_headers)

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
raise HttpOperationError(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize("MeetingInfo", response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

fetch_participant.metadata = {"url": "/v1/meetings/{meetingId}"}