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 Room Meeting Info API endpoint - Proposed Alternate Implementation #130

Merged
merged 2 commits into from
Jul 13, 2020
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
11 changes: 10 additions & 1 deletion docs/user/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ Room
:inherited-members:


.. _RoomMeetingInfo:

Room Meeting Info
-----------------

.. autoclass:: RoomMeetingInfo()
:inherited-members:


.. _Team:

Team
Expand All @@ -266,7 +275,7 @@ Team
:inherited-members:


.. _Team Membership:
.. _TeamMembership:

Team Membership
---------------
Expand Down
1 change: 1 addition & 0 deletions docs/user/api_structure_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
| | :ref:`rooms` | :meth:`list() <webeteamssdk.api.rooms.RoomsAPI.list>` |
| | | :meth:`create() <webeteamssdk.api.rooms.RoomsAPI.create>` |
| | | :meth:`get() <webeteamssdk.api.rooms.RoomsAPI.get>` |
| | | :meth:`get_meeting_info() <webeteamssdk.api.rooms.RoomsAPI.get_meeting_info>` |
| | | :meth:`update() <webeteamssdk.api.rooms.RoomsAPI.update>` |
| | | :meth:`delete() <webeteamssdk.api.rooms.RoomsAPI.delete>` |
+------------------------+---------------------------+---------------------------------------------------------------------------------+
Expand Down
10 changes: 10 additions & 0 deletions tests/api/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def is_valid_room(obj):
return isinstance(obj, webexteamssdk.Room) and obj.id is not None


def is_valid_room_meeting_info(obj):
return (isinstance(obj, webexteamssdk.RoomMeetingInfo)
and obj.roomId is not None)


def are_valid_rooms(iterable):
return all([is_valid_room(obj) for obj in iterable])

Expand Down Expand Up @@ -156,6 +161,11 @@ def test_get_room_details(api, group_room):
assert is_valid_room(room)


def test_get_room_meeting_info(api, group_room):
room_meeting_info = api.rooms.get_meeting_info(group_room.id)
assert is_valid_room_meeting_info(room_meeting_info)


def test_update_room_title(api, group_room):
new_title = create_string("Updated Group Room")
room = api.rooms.update(group_room.id, title=new_title)
Expand Down
2 changes: 1 addition & 1 deletion webexteamssdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from .models.immutable import (
AccessToken, AdminAuditEvent, AttachmentAction, Event, GuestIssuerToken,
immutable_data_factory, License, Membership, Message, Organization, Person,
Role, Room, Team, TeamMembership, Webhook, WebhookEvent,
Role, Room, RoomMeetingInfo, Team, TeamMembership, Webhook, WebhookEvent,
)
from .models.simple import simple_data_factory, SimpleDataModel
from .utils import WebexTeamsDateTime
Expand Down
32 changes: 29 additions & 3 deletions webexteamssdk/api/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, session, object_factory):
self._object_factory = object_factory

@generator_container
def list(self, teamId=None, type=None, sortBy=None, max=None,
def list(self, teamId=None, type=None, sortBy=None, max=100,
**request_parameters):
"""List rooms.

Expand Down Expand Up @@ -189,7 +189,33 @@ def get(self, roomId):
# Return a room object created from the response JSON data
return self._object_factory(OBJECT_TYPE, json_data)

def update(self, roomId, title=None, **request_parameters):
def get_meeting_info(self, roomId):
"""Get the meeting details for a room.

Args:
roomId(basestring): The unique identifier for the room.

Returns:
RoomMeetingInfo: A Room Meeting Info object with the meeting
details for the room such as the SIP address, meeting URL,
toll-free and toll dial-in numbers.

Raises:
TypeError: If the parameter types are incorrect.
ApiError: If the Webex Teams cloud returns an error.

"""
check_type(roomId, basestring)

# API request
json_data = self._session.get(
API_ENDPOINT + '/' + roomId + '/meetingInfo',
)

# Return a room meeting info object created from the response JSON data
return self._object_factory("room_meeting_info", json_data)

def update(self, roomId, title, **request_parameters):
"""Update details for a room, by ID.

Args:
Expand All @@ -207,7 +233,7 @@ def update(self, roomId, title=None, **request_parameters):

"""
check_type(roomId, basestring)
check_type(roomId, basestring, optional=True)
check_type(roomId, basestring)

put_data = dict_from_items_with_values(
request_parameters,
Expand Down
6 changes: 6 additions & 0 deletions webexteamssdk/models/immutable.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from .mixins.person import PersonBasicPropertiesMixin
from .mixins.role import RoleBasicPropertiesMixin
from .mixins.room import RoomBasicPropertiesMixin
from .mixins.room_meeting_info import RoomMeetingInfoBasicPropertiesMixin
from .mixins.team import TeamBasicPropertiesMixin
from .mixins.team_membership import TeamMembershipBasicPropertiesMixin
from .mixins.webhook import WebhookBasicPropertiesMixin
Expand Down Expand Up @@ -240,6 +241,10 @@ class Room(ImmutableData, RoomBasicPropertiesMixin):
"""Webex Teams Room data model."""


class RoomMeetingInfo(ImmutableData, RoomMeetingInfoBasicPropertiesMixin):
"""Webex Teams Room Meeting Info data model."""


class Team(ImmutableData, TeamBasicPropertiesMixin):
"""Webex Teams Team data model."""

Expand Down Expand Up @@ -278,6 +283,7 @@ class GuestIssuerToken(ImmutableData, GuestIssuerTokenBasicPropertiesMixin):
person=Person,
role=Role,
room=Room,
room_meeting_info=RoomMeetingInfo,
team=Team,
team_membership=TeamMembership,
webhook=Webhook,
Expand Down
28 changes: 14 additions & 14 deletions webexteamssdk/models/mixins/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class RoomBasicPropertiesMixin(object):
@property
def id(self):
"""A unique identifier for the room."""
return self._json_data.get('id')
return self._json_data.get("id")

@property
def title(self):
"""A user-friendly name for the room."""
return self._json_data.get('title')
return self._json_data.get("title")

@property
def type(self):
Expand All @@ -57,22 +57,22 @@ def type(self):

`group`: Group room
"""
return self._json_data.get('type')
return self._json_data.get("type")

@property
def isLocked(self):
"""Whether the room is moderated (locked) or not."""
return self._json_data.get('isLocked')
return self._json_data.get("isLocked")

@property
def teamId(self):
"""The ID for the team with which this room is associated."""
return self._json_data.get('teamId')
return self._json_data.get("teamId")

@property
def lastActivity(self):
"""The date and time of the room's last activity."""
last_activity = self._json_data.get('lastActivity')
"""The date and time of the room"s last activity."""
last_activity = self._json_data.get("lastActivity")
if last_activity:
return WebexTeamsDateTime.strptime(last_activity)
else:
Expand All @@ -81,18 +81,18 @@ def lastActivity(self):
@property
def creatorId(self):
"""The ID of the person who created this room."""
return self._json_data.get('creatorId')

@property
def ownerId(self):
"""The ID of the organization which owns this room."""
return self._json_data.get('ownerId')
return self._json_data.get("creatorId")

@property
def created(self):
"""The date and time the room was created."""
created = self._json_data.get('created')
created = self._json_data.get("created")
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None

@property
def ownerId(self):
"""The ID of the organization which owns this room."""
return self._json_data.get("ownerId")
67 changes: 67 additions & 0 deletions webexteamssdk/models/mixins/room_meeting_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
"""Webex Teams Room Meeting Info data model.

Copyright (c) 2016-2019 Cisco and/or its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""


from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)

from builtins import *


class RoomMeetingInfoBasicPropertiesMixin(object):
"""Room basic properties."""

@property
def roomId(self):
"""A unique identifier for the room."""
return self._json_data.get("roomId")

@property
def meetingLink(self):
"""The Webex meeting URL for the room."""
return self._json_data.get("meetingLink")

@property
def sipAddress(self):
"""The SIP address for the room."""
return self._json_data.get("sipAddress")

@property
def meetingNumber(self):
"""The Webex meeting number for the room."""
return self._json_data.get("meetingNumber")

@property
def callInTollFreeNumber(self):
"""The toll-free PSTN number for the room."""
return self._json_data.get("callInTollFreeNumber")

@property
def callInTollNumber(self):
"""The toll (local) PSTN number for the room."""
return self._json_data.get("callInTollNumber")