Skip to content

Commit 88f9a80

Browse files
author
Ava Thorn
committed
Added room tabs
1 parent 6733127 commit 88f9a80

File tree

4 files changed

+321
-0
lines changed

4 files changed

+321
-0
lines changed

webexteamssdk/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .people import PeopleAPI
4646
from .roles import RolesAPI
4747
from .rooms import RoomsAPI
48+
from .room_tabs import RoomTabsAPI
4849
from .team_memberships import TeamMembershipsAPI
4950
from .teams import TeamsAPI
5051
from .webhooks import WebhooksAPI
@@ -211,6 +212,7 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
211212
self.people = PeopleAPI(self._session, object_factory)
212213
self.roles = RolesAPI(self._session, object_factory)
213214
self.rooms = RoomsAPI(self._session, object_factory)
215+
self.room_tabs = RoomTabsAPI(self._session, object_factory)
214216
self.teams = TeamsAPI(self._session, object_factory)
215217
self.team_memberships = TeamMembershipsAPI(
216218
self._session, object_factory,

webexteamssdk/api/room_tabs.py

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex Teams Room Tabs API wrapper.
3+
4+
Copyright (c) 2016-2020 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+
from past.builtins import basestring
36+
37+
from ..generator_containers import generator_container
38+
from ..restsession import RestSession
39+
from ..utils import (
40+
check_type,
41+
dict_from_items_with_values,
42+
)
43+
44+
45+
API_ENDPOINT = 'room/tabs'
46+
OBJECT_TYPE = 'room_tab'
47+
48+
49+
class RoomTabsAPI(object):
50+
"""Webex Teams Room Tabs API.
51+
52+
Wraps the Webex Teams Room Tabs API and exposes the API as native Python
53+
methods that return native Python objects.
54+
55+
"""
56+
57+
def __init__(self, session, object_factory):
58+
"""Initialize a new RoomTabsAPI object with the provided RestSession.
59+
60+
Args:
61+
session(RestSession): The RESTful session object to be used for
62+
API calls to the Webex Teams service.
63+
64+
Raises:
65+
TypeError: If the parameter types are incorrect.
66+
67+
"""
68+
check_type(session, RestSession)
69+
70+
super(RoomTabsAPI, self).__init__()
71+
72+
self._session = session
73+
self._object_factory = object_factory
74+
75+
@generator_container
76+
def list(self, roomId, **request_parameters):
77+
"""Lists all Room Tabs of a room. roomId query parameter is required to retrieve the response.
78+
79+
This method supports Webex Teams's implementation of RFC5988 Web
80+
Linking to provide pagination support. It returns a generator
81+
container that incrementally yields all room tabs returned by the
82+
query. The generator will automatically request additional 'pages' of
83+
responses from Webex as needed until all responses have been returned.
84+
The container makes the generator safe for reuse. A new API call will
85+
be made, using the same parameters that were specified when the
86+
generator was created, every time a new iterator is requested from the
87+
container.
88+
89+
Args:
90+
roomId(basestring): List Room Tabs associated with a room, by ID.
91+
**request_parameters: Additional request parameters (provides
92+
support for parameters that may be added in the future).
93+
94+
Returns:
95+
GeneratorContainer: A GeneratorContainer which, when iterated,
96+
yields the room tabs returned by the Webex Teams query.
97+
98+
Raises:
99+
TypeError: If the parameter types are incorrect.
100+
ApiError: If the Webex Teams cloud returns an error.
101+
102+
"""
103+
check_type(roomId, basestring)
104+
105+
params = dict_from_items_with_values(
106+
request_parameters,
107+
roomId=roomId,
108+
)
109+
110+
# API request - get items
111+
items = self._session.get_items(API_ENDPOINT, params=params)
112+
113+
# Yield room objects created from the returned items JSON objects
114+
for item in items:
115+
yield self._object_factory(OBJECT_TYPE, item)
116+
117+
def create(self, roomId, contentUrl, displayName, **request_parameters):
118+
"""Create a room tab.
119+
120+
Add a tab with a content url to a room that can be accessed in the room
121+
122+
Args:
123+
roomId(basestring): A unique identifier for the room.
124+
contentUrl(basestring): Content Url of the Room Tab. Needs to use the https protocol.
125+
displayName(basestring): A user-friendly name for the room.
126+
**request_parameters: Additional request parameters (provides
127+
support for parameters that may be added in the future).
128+
Returns:
129+
RoomTab: A Room Tab with the details of the created room tab.
130+
131+
Raises:
132+
TypeError: If the parameter types are incorrect.
133+
ApiError: If the Webex Teams cloud returns an error.
134+
135+
"""
136+
check_type(roomId, basestring)
137+
check_type(contentUrl, basestring)
138+
check_type(displayName, basestring)
139+
140+
post_data = dict_from_items_with_values(
141+
request_parameters,
142+
roomId=roomId,
143+
contentUrl=contentUrl,
144+
displayName=displayName,
145+
)
146+
147+
# API request
148+
json_data = self._session.post(API_ENDPOINT, json=post_data)
149+
150+
# Return a room object created from the response JSON data
151+
return self._object_factory(OBJECT_TYPE, json_data)
152+
153+
# def get(self, roomId):
154+
# """Get the details of a room tab, by ID.
155+
156+
# Args:
157+
# roomId(basestring): The ID of the room to be retrieved.
158+
159+
# Returns:
160+
# Room: A Room object with the details of the requested room.
161+
162+
# Raises:
163+
# TypeError: If the parameter types are incorrect.
164+
# ApiError: If the Webex Teams cloud returns an error.
165+
166+
# """
167+
# check_type(roomId, basestring)
168+
169+
# # API request
170+
# json_data = self._session.get(API_ENDPOINT + '/' + roomId)
171+
172+
# # Return a room object created from the response JSON data
173+
# return self._object_factory(OBJECT_TYPE, json_data)
174+
175+
def update(self, roomTabId, roomId, contentUrl, displayName, **request_parameters):
176+
"""Updates the content url of a Room Tab by ID.
177+
178+
Args:
179+
roomTabId(basestring): The unique identifier for the Room Tab.
180+
roomId(basestring): The room ID.
181+
contentUrl(basestring): Content Url of the Room Tab. Needs to use the https protocol.
182+
displayName(basestring): A user-friendly name for the room.
183+
**request_parameters: Additional request parameters (provides
184+
support for parameters that may be added in the future).
185+
186+
Returns:
187+
Room: A Room object with the updated Webex Teams room details.
188+
189+
Raises:
190+
TypeError: If the parameter types are incorrect.
191+
ApiError: If the Webex Teams cloud returns an error.
192+
193+
"""
194+
check_type(roomTabId, basestring)
195+
check_type(roomId, basestring)
196+
check_type(contentUrl, basestring)
197+
check_type(displayName, basestring)
198+
199+
put_data = dict_from_items_with_values(
200+
request_parameters,
201+
roomTabId=roomTabId,
202+
roomId=roomId,
203+
contentUrl=contentUrl,
204+
displayName=displayName,
205+
)
206+
207+
# API request
208+
json_data = self._session.put(API_ENDPOINT + '/' + roomTabId,
209+
json=put_data)
210+
211+
# Return a room object created from the response JSON data
212+
return self._object_factory(OBJECT_TYPE, json_data)
213+
214+
215+
def delete(self, roomTabId):
216+
"""Delete a room tab.
217+
218+
Args:
219+
roomTabId(basestring): The ID of the room tab to be deleted.
220+
221+
Raises:
222+
TypeError: If the parameter types are incorrect.
223+
ApiError: If the Webex Teams cloud returns an error.
224+
225+
"""
226+
check_type(roomTabId, basestring)
227+
228+
# API request
229+
self._session.delete(API_ENDPOINT + '/' + roomTabId)

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_tab import RoomTabBasicPropertiesMixin
5859
from .mixins.room_meeting_info import RoomMeetingInfoBasicPropertiesMixin
5960
from .mixins.team import TeamBasicPropertiesMixin
6061
from .mixins.team_membership import TeamMembershipBasicPropertiesMixin
@@ -241,6 +242,10 @@ class Room(ImmutableData, RoomBasicPropertiesMixin):
241242
"""Webex Teams Room data model."""
242243

243244

245+
class RoomTab(ImmutableData, RoomTabBasicPropertiesMixin):
246+
"""Webex Teams Room Tab data model."""
247+
248+
244249
class RoomMeetingInfo(ImmutableData, RoomMeetingInfoBasicPropertiesMixin):
245250
"""Webex Teams Room Meeting Info data model."""
246251

@@ -283,6 +288,7 @@ class GuestIssuerToken(ImmutableData, GuestIssuerTokenBasicPropertiesMixin):
283288
person=Person,
284289
role=Role,
285290
room=Room,
291+
room_tab=RoomTab,
286292
room_meeting_info=RoomMeetingInfo,
287293
team=Team,
288294
team_membership=TeamMembership,
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex Teams Room data model.
3+
4+
Copyright (c) 2016-2020 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+
from webexteamssdk.utils import WebexTeamsDateTime
36+
37+
38+
class RoomTabBasicPropertiesMixin(object):
39+
"""Room Tab basic properties."""
40+
41+
@property
42+
def id(self):
43+
"""A unique identifier for the Room Tab."""
44+
return self._json_data.get("id")
45+
46+
@property
47+
def room(self):
48+
"""A unique identifier for the room."""
49+
return self._json_data.get("roomId")
50+
51+
@property
52+
def roomType(self):
53+
"""The room type.
54+
55+
Room Type Enum:
56+
`direct`: 1:1 room
57+
58+
`group`: Group room
59+
"""
60+
return self._json_data.get("roomType")
61+
62+
@property
63+
def displayName(self):
64+
"""User-friendly name for the room tab."""
65+
return self._json_data.get("displayName")
66+
67+
@property
68+
def contentUrl(self):
69+
"""Content Url of the Room Tab."""
70+
return self._json_data.get("contentUrl")
71+
72+
@property
73+
def creatorId(self):
74+
"""The person ID of the person who created this Room Tab."""
75+
return self._json_data.get("creatorId")
76+
77+
@property
78+
def created(self):
79+
"""The date and time when the Room Tab was created."""
80+
created = self._json_data.get("created")
81+
if created:
82+
return WebexTeamsDateTime.strptime(created)
83+
else:
84+
return None

0 commit comments

Comments
 (0)