Skip to content

Commit 3aca1fe

Browse files
authored
Merge pull request #130 from CiscoDevNet/feature-111
Add Room Meeting Info API endpoint - Proposed Alternate Implementation
2 parents 496507a + 25f1227 commit 3aca1fe

File tree

8 files changed

+138
-19
lines changed

8 files changed

+138
-19
lines changed

docs/user/api.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ Room
257257
:inherited-members:
258258

259259

260+
.. _RoomMeetingInfo:
261+
262+
Room Meeting Info
263+
-----------------
264+
265+
.. autoclass:: RoomMeetingInfo()
266+
:inherited-members:
267+
268+
260269
.. _Team:
261270

262271
Team
@@ -266,7 +275,7 @@ Team
266275
:inherited-members:
267276

268277

269-
.. _Team Membership:
278+
.. _TeamMembership:
270279

271280
Team Membership
272281
---------------

docs/user/api_structure_table.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
| | :ref:`rooms` | :meth:`list() <webeteamssdk.api.rooms.RoomsAPI.list>` |
4343
| | | :meth:`create() <webeteamssdk.api.rooms.RoomsAPI.create>` |
4444
| | | :meth:`get() <webeteamssdk.api.rooms.RoomsAPI.get>` |
45+
| | | :meth:`get_meeting_info() <webeteamssdk.api.rooms.RoomsAPI.get_meeting_info>` |
4546
| | | :meth:`update() <webeteamssdk.api.rooms.RoomsAPI.update>` |
4647
| | | :meth:`delete() <webeteamssdk.api.rooms.RoomsAPI.delete>` |
4748
+------------------------+---------------------------+---------------------------------------------------------------------------------+

tests/api/test_rooms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def is_valid_room(obj):
3636
return isinstance(obj, webexteamssdk.Room) and obj.id is not None
3737

3838

39+
def is_valid_room_meeting_info(obj):
40+
return (isinstance(obj, webexteamssdk.RoomMeetingInfo)
41+
and obj.roomId is not None)
42+
43+
3944
def are_valid_rooms(iterable):
4045
return all([is_valid_room(obj) for obj in iterable])
4146

@@ -156,6 +161,11 @@ def test_get_room_details(api, group_room):
156161
assert is_valid_room(room)
157162

158163

164+
def test_get_room_meeting_info(api, group_room):
165+
room_meeting_info = api.rooms.get_meeting_info(group_room.id)
166+
assert is_valid_room_meeting_info(room_meeting_info)
167+
168+
159169
def test_update_room_title(api, group_room):
160170
new_title = create_string("Updated Group Room")
161171
room = api.rooms.update(group_room.id, title=new_title)

webexteamssdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from .models.immutable import (
4747
AccessToken, AdminAuditEvent, AttachmentAction, Event, GuestIssuerToken,
4848
immutable_data_factory, License, Membership, Message, Organization, Person,
49-
Role, Room, Team, TeamMembership, Webhook, WebhookEvent,
49+
Role, Room, RoomMeetingInfo, Team, TeamMembership, Webhook, WebhookEvent,
5050
)
5151
from .models.simple import simple_data_factory, SimpleDataModel
5252
from .utils import WebexTeamsDateTime

webexteamssdk/api/rooms.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, session, object_factory):
7373
self._object_factory = object_factory
7474

7575
@generator_container
76-
def list(self, teamId=None, type=None, sortBy=None, max=None,
76+
def list(self, teamId=None, type=None, sortBy=None, max=100,
7777
**request_parameters):
7878
"""List rooms.
7979
@@ -189,7 +189,33 @@ def get(self, roomId):
189189
# Return a room object created from the response JSON data
190190
return self._object_factory(OBJECT_TYPE, json_data)
191191

192-
def update(self, roomId, title=None, **request_parameters):
192+
def get_meeting_info(self, roomId):
193+
"""Get the meeting details for a room.
194+
195+
Args:
196+
roomId(basestring): The unique identifier for the room.
197+
198+
Returns:
199+
RoomMeetingInfo: A Room Meeting Info object with the meeting
200+
details for the room such as the SIP address, meeting URL,
201+
toll-free and toll dial-in numbers.
202+
203+
Raises:
204+
TypeError: If the parameter types are incorrect.
205+
ApiError: If the Webex Teams cloud returns an error.
206+
207+
"""
208+
check_type(roomId, basestring)
209+
210+
# API request
211+
json_data = self._session.get(
212+
API_ENDPOINT + '/' + roomId + '/meetingInfo',
213+
)
214+
215+
# Return a room meeting info object created from the response JSON data
216+
return self._object_factory("room_meeting_info", json_data)
217+
218+
def update(self, roomId, title, **request_parameters):
193219
"""Update details for a room, by ID.
194220
195221
Args:
@@ -207,7 +233,7 @@ def update(self, roomId, title=None, **request_parameters):
207233
208234
"""
209235
check_type(roomId, basestring)
210-
check_type(roomId, basestring, optional=True)
236+
check_type(roomId, basestring)
211237

212238
put_data = dict_from_items_with_values(
213239
request_parameters,

webexteamssdk/models/immutable.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from .mixins.person import PersonBasicPropertiesMixin
5656
from .mixins.role import RoleBasicPropertiesMixin
5757
from .mixins.room import RoomBasicPropertiesMixin
58+
from .mixins.room_meeting_info import RoomMeetingInfoBasicPropertiesMixin
5859
from .mixins.team import TeamBasicPropertiesMixin
5960
from .mixins.team_membership import TeamMembershipBasicPropertiesMixin
6061
from .mixins.webhook import WebhookBasicPropertiesMixin
@@ -240,6 +241,10 @@ class Room(ImmutableData, RoomBasicPropertiesMixin):
240241
"""Webex Teams Room data model."""
241242

242243

244+
class RoomMeetingInfo(ImmutableData, RoomMeetingInfoBasicPropertiesMixin):
245+
"""Webex Teams Room Meeting Info data model."""
246+
247+
243248
class Team(ImmutableData, TeamBasicPropertiesMixin):
244249
"""Webex Teams Team data model."""
245250

@@ -278,6 +283,7 @@ class GuestIssuerToken(ImmutableData, GuestIssuerTokenBasicPropertiesMixin):
278283
person=Person,
279284
role=Role,
280285
room=Room,
286+
room_meeting_info=RoomMeetingInfo,
281287
team=Team,
282288
team_membership=TeamMembership,
283289
webhook=Webhook,

webexteamssdk/models/mixins/room.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class RoomBasicPropertiesMixin(object):
4141
@property
4242
def id(self):
4343
"""A unique identifier for the room."""
44-
return self._json_data.get('id')
44+
return self._json_data.get("id")
4545

4646
@property
4747
def title(self):
4848
"""A user-friendly name for the room."""
49-
return self._json_data.get('title')
49+
return self._json_data.get("title")
5050

5151
@property
5252
def type(self):
@@ -57,22 +57,22 @@ def type(self):
5757
5858
`group`: Group room
5959
"""
60-
return self._json_data.get('type')
60+
return self._json_data.get("type")
6161

6262
@property
6363
def isLocked(self):
6464
"""Whether the room is moderated (locked) or not."""
65-
return self._json_data.get('isLocked')
65+
return self._json_data.get("isLocked")
6666

6767
@property
6868
def teamId(self):
6969
"""The ID for the team with which this room is associated."""
70-
return self._json_data.get('teamId')
70+
return self._json_data.get("teamId")
7171

7272
@property
7373
def lastActivity(self):
74-
"""The date and time of the room's last activity."""
75-
last_activity = self._json_data.get('lastActivity')
74+
"""The date and time of the room"s last activity."""
75+
last_activity = self._json_data.get("lastActivity")
7676
if last_activity:
7777
return WebexTeamsDateTime.strptime(last_activity)
7878
else:
@@ -81,18 +81,18 @@ def lastActivity(self):
8181
@property
8282
def creatorId(self):
8383
"""The ID of the person who created this room."""
84-
return self._json_data.get('creatorId')
85-
86-
@property
87-
def ownerId(self):
88-
"""The ID of the organization which owns this room."""
89-
return self._json_data.get('ownerId')
84+
return self._json_data.get("creatorId")
9085

9186
@property
9287
def created(self):
9388
"""The date and time the room was created."""
94-
created = self._json_data.get('created')
89+
created = self._json_data.get("created")
9590
if created:
9691
return WebexTeamsDateTime.strptime(created)
9792
else:
9893
return None
94+
95+
@property
96+
def ownerId(self):
97+
"""The ID of the organization which owns this room."""
98+
return self._json_data.get("ownerId")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex Teams Room Meeting Info data model.
3+
4+
Copyright (c) 2016-2019 Cisco and/or its affiliates.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
"""
24+
25+
26+
from __future__ import (
27+
absolute_import,
28+
division,
29+
print_function,
30+
unicode_literals,
31+
)
32+
33+
from builtins import *
34+
35+
36+
class RoomMeetingInfoBasicPropertiesMixin(object):
37+
"""Room basic properties."""
38+
39+
@property
40+
def roomId(self):
41+
"""A unique identifier for the room."""
42+
return self._json_data.get("roomId")
43+
44+
@property
45+
def meetingLink(self):
46+
"""The Webex meeting URL for the room."""
47+
return self._json_data.get("meetingLink")
48+
49+
@property
50+
def sipAddress(self):
51+
"""The SIP address for the room."""
52+
return self._json_data.get("sipAddress")
53+
54+
@property
55+
def meetingNumber(self):
56+
"""The Webex meeting number for the room."""
57+
return self._json_data.get("meetingNumber")
58+
59+
@property
60+
def callInTollFreeNumber(self):
61+
"""The toll-free PSTN number for the room."""
62+
return self._json_data.get("callInTollFreeNumber")
63+
64+
@property
65+
def callInTollNumber(self):
66+
"""The toll (local) PSTN number for the room."""
67+
return self._json_data.get("callInTollNumber")

0 commit comments

Comments
 (0)