Skip to content

Commit a427827

Browse files
committed
Added /meetings/templates endpoint
1 parent 0c83e76 commit a427827

File tree

5 files changed

+325
-2
lines changed

5 files changed

+325
-2
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: MeetingTemplate
2+
endpoint: meetings/templates
3+
object_type: meetingTemplate
4+
methods:
5+
- list
6+
- get
7+
query_parameters:
8+
- name: templateType
9+
description: Meeting template types (meeting, webinar)
10+
optional: True
11+
type: basestring
12+
- name: locale
13+
description: Locale for the meeting template (i.e. en_US)
14+
optional: True
15+
type: basestring
16+
- name: isDefault
17+
description: Flag to indicate if default or non-default meeting templates are returned
18+
optional: True
19+
type: bool
20+
- name: isStandard
21+
description: Flag to indicate if standard or non-standard meeting templates are returned
22+
optional: True
23+
type: bool
24+
- name: hostEmail
25+
description: Email address of a meeting host (Requires admin-level scope)
26+
optional: True
27+
type: bool
28+
- name: siteUrl
29+
description: URL of the Webex site from which we are listing.
30+
optional: True
31+
type: bool
32+
list:
33+
properties:
34+
- name: id
35+
description: Unique id for meeting template
36+
type: basestring
37+
- name: name
38+
description: Name of the meeting template
39+
type: basestring
40+
- name: locale
41+
description: Locale for the meeting template
42+
type: basestring
43+
- name: siteUrl
44+
description: Site URL for the meeting template
45+
type: basestring
46+
- name: templateType
47+
description: Type of the meeting template (meeting, webinar)
48+
type: basestring
49+
- name: isDefault
50+
description: Whether or not the meeting template is a default template
51+
type: bool
52+
- name: isStandard
53+
description: Whether or not the meeting template is a standard template
54+
type: bool
55+
- name: meeting
56+
description: Meeting object which is used to create a meeting by the meeting template. Please note that the meeting object should be used to create a meeting immediately.
57+
type: dict

webexteamssdk/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .teams import TeamsAPI
5151
from .webhooks import WebhooksAPI
5252
from .meetings import MeetingsAPI
53+
from .meeting_templates import MeetingTemplatesAPI
5354
import os
5455

5556

@@ -220,6 +221,7 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
220221
self.webhooks = WebhooksAPI(self._session, object_factory)
221222
self.recordings = RecordingsAPI(self._session, object_factory)
222223
self.meetings = MeetingsAPI(self._session, object_factory)
224+
self.meeting_templates = MeetingTemplatesAPI(self._session, object_factory)
223225

224226
@property
225227
def access_token(self):
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex MeetingTemplates API wrapper.
3+
4+
Copyright (c) 2016-2022 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 = 'meetings/templates'
46+
OBJECT_TYPE = 'meetingTemplate'
47+
48+
49+
class MeetingTemplatesAPI(object):
50+
"""Webex MeetingTemplates API.
51+
52+
Wraps the Webex MeetingTemplates 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+
"""Init a new MeetingTemplatesAPI 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(MeetingTemplatesAPI, self).__init__()
71+
72+
self._session = session
73+
self._object_factory = object_factory
74+
75+
@generator_container
76+
def list(self, templateType=None,
77+
locale=None,
78+
isDefault=None,
79+
isStandard=None,
80+
hostEmail=None,
81+
siteUrl=None,
82+
headers={},
83+
**request_parameters):
84+
85+
"""List meetingTemplates.
86+
87+
Use query parameters to filter the response.
88+
89+
This method supports Webex Teams's implementation of RFC5988 Web
90+
Linking to provide pagination support. It returns a generator
91+
container that incrementally yields all memberships returned by the
92+
query. The generator will automatically request additional 'pages' of
93+
responses from Webex as needed until all responses have been returned.
94+
The container makes the generator safe for reuse. A new API call will
95+
be made, using the same parameters that were specified when the
96+
generator was created, every time a new iterator is requested from the
97+
container.
98+
99+
Args:
100+
templateType (basestring): Meeting template types (meeting, webinar)
101+
locale (basestring): Locale for the meeting template (i.e. en_US)
102+
isDefault (bool): Flag to indicate if default or non-default meeting templates are returned
103+
isStandard (bool): Flag to indicate if standard or non-standard meeting templates are returned
104+
hostEmail (bool): Email address of a meeting host (Requires admin-level scope)
105+
siteUrl (bool): URL of the Webex site from which we are listing.
106+
headers(dict): Additional headers to be passed.
107+
**request_parameters: Additional request parameters (provides
108+
support for parameters that may be added in the future).
109+
110+
Returns:
111+
GeneratorContainer: A GeneratorContainer which, when iterated,
112+
yields the meetingTemplates returned by the Webex query.
113+
114+
Raises:
115+
TypeError: If the parameter types are incorrect.
116+
ApiError: If the Webex Teams cloud returns an error.
117+
118+
"""
119+
check_type(templateType, basestring, optional=True)
120+
check_type(locale, basestring, optional=True)
121+
check_type(isDefault, bool, optional=True)
122+
check_type(isStandard, bool, optional=True)
123+
check_type(hostEmail, bool, optional=True)
124+
check_type(siteUrl, bool, optional=True)
125+
126+
127+
params = dict_from_items_with_values(
128+
request_parameters,
129+
templateType=templateType,
130+
locale=locale,
131+
isDefault=isDefault,
132+
isStandard=isStandard,
133+
hostEmail=hostEmail,
134+
siteUrl=siteUrl,
135+
136+
)
137+
138+
# API request - get items
139+
140+
# Update headers
141+
for k, v in headers.items():
142+
self._session.headers[k] = v
143+
items = self._session.get_items(API_ENDPOINT, params=params)
144+
145+
# Remove headers
146+
for k, v in headers.items():
147+
del self._session.headers[k]
148+
149+
# Yield membership objects created from the returned items JSON objects
150+
for item in items:
151+
yield self._object_factory(OBJECT_TYPE, item)
152+
153+
154+
155+
156+
def get(self, meetingTemplateId):
157+
"""Get details for a meetingTemplate, by ID.
158+
159+
Args:
160+
meetingTemplateId(basestring): The meetingTemplate ID.
161+
162+
Returns:
163+
MeetingTemplate: A MeetingTemplate object with the details of the requested
164+
meetingTemplate.
165+
166+
Raises:
167+
TypeError: If the parameter types are incorrect.
168+
ApiError: If the Webex Teams cloud returns an error.
169+
170+
"""
171+
check_type(meetingTemplateId, basestring)
172+
173+
# API request
174+
json_data = self._session.get(API_ENDPOINT + '/' + meetingTemplateId)
175+
176+
# Return a membership object created from the response JSON data
177+
return self._object_factory(OBJECT_TYPE, json_data)
178+
179+
180+
181+
182+

webexteamssdk/models/immutable.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
from .mixins.webhook_event import WebhookEventBasicPropertiesMixin
6363
from .mixins.recording import RecordingBasicPropertiesMixin
6464
from .mixins.meetings import MeetingBasicPropertiesMixin
65-
65+
from .mixins.meeting_templates import MeetingTemplateBasicPropertiesMixin
6666

6767
class ImmutableData(object):
6868
"""Model a Webex Teams JSON object as an immutable native Python object."""
@@ -278,6 +278,9 @@ class Recording(ImmutableData, RecordingBasicPropertiesMixin):
278278
class Meeting(ImmutableData, MeetingBasicPropertiesMixin):
279279
"""Webex Meeting data model"""
280280

281+
class MeetingTemplate(ImmutableData, MeetingTemplateBasicPropertiesMixin):
282+
"""Webex MeetingTemplate data model"""
283+
281284
immutable_data_models = defaultdict(
282285
lambda: ImmutableData,
283286
access_token=AccessToken,
@@ -298,7 +301,8 @@ class Meeting(ImmutableData, MeetingBasicPropertiesMixin):
298301
webhook_event=WebhookEvent,
299302
guest_issuer_token=GuestIssuerToken,
300303
recording=Recording,
301-
meeting=Meeting
304+
meeting=Meeting,
305+
meetingTemplate=MeetingTemplate
302306
)
303307

304308

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex MeetingTemplates data model.
3+
4+
Copyright (c) 2016-2022 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+
from __future__ import (
26+
absolute_import,
27+
division,
28+
print_function,
29+
unicode_literals,
30+
)
31+
32+
from builtins import *
33+
34+
35+
36+
class MeetingTemplateBasicPropertiesMixin(object):
37+
"""MeetingTemplate basic properties."""
38+
39+
@property
40+
def id(self):
41+
"""Unique id for meeting template"""
42+
return self._json_data.get("id")
43+
44+
@property
45+
def name(self):
46+
"""Name of the meeting template"""
47+
return self._json_data.get("name")
48+
49+
@property
50+
def locale(self):
51+
"""Locale for the meeting template"""
52+
return self._json_data.get("locale")
53+
54+
@property
55+
def siteUrl(self):
56+
"""Site URL for the meeting template"""
57+
return self._json_data.get("siteUrl")
58+
59+
@property
60+
def templateType(self):
61+
"""Type of the meeting template (meeting, webinar)"""
62+
return self._json_data.get("templateType")
63+
64+
@property
65+
def isDefault(self):
66+
"""Whether or not the meeting template is a default template"""
67+
return self._json_data.get("isDefault")
68+
69+
@property
70+
def isStandard(self):
71+
"""Whether or not the meeting template is a standard template"""
72+
return self._json_data.get("isStandard")
73+
74+
@property
75+
def meeting(self):
76+
"""Meeting object which is used to create a meeting by the meeting template. Please note that the meeting object should be used to create a meeting immediately."""
77+
return self._json_data.get("meeting")
78+

0 commit comments

Comments
 (0)