Skip to content

Commit 09e8e31

Browse files
committed
adding backwards compatibility
1 parent 3c360fb commit 09e8e31

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

opentok/endpoints.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import warnings
2+
3+
14
class Endpoints(object):
25
"""
36
For internal use.
@@ -12,12 +15,29 @@ def get_session_url(self):
1215
url = self.api_url + "/session/create"
1316
return url
1417

18+
def session_url(self):
19+
warnings.warn(
20+
"endpoints.session_url is deprecated (use endpoints.get_session_url instead).",
21+
DeprecationWarning,
22+
stacklevel=2,
23+
)
24+
25+
return self.get_session_url()
26+
1527
def get_archive_url(self, archive_id=None):
1628
url = self.api_url + "/v2/project/" + self.api_key + "/archive"
1729
if archive_id:
1830
url = url + "/" + archive_id
1931
return url
2032

33+
def archive_url(self, archive_id=None):
34+
warnings.warn(
35+
"endpoints.archive_url is deprecated (use endpoints.get_archive_url instead).",
36+
DeprecationWarning,
37+
stacklevel=2,
38+
)
39+
return self.get_archive_url(archive_id)
40+
2141
def get_signaling_url(self, session_id, connection_id=None):
2242
url = self.api_url + "/v2/project/" + self.api_key + "/session/" + session_id
2343

@@ -27,6 +47,14 @@ def get_signaling_url(self, session_id, connection_id=None):
2747
url += "/signal"
2848
return url
2949

50+
def signaling_url(self, session_id, connection_id=None):
51+
warnings.warn(
52+
"endpoints.signaling_url is deprecated (use endpoints.get_signaling_url instead).",
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
56+
return self.get_signaling_url(session_id, connection_id)
57+
3058
def get_stream_url(self, session_id, stream_id=None):
3159
""" this method returns the url to get streams information """
3260
url = (
@@ -41,6 +69,14 @@ def get_stream_url(self, session_id, stream_id=None):
4169
url = url + "/" + stream_id
4270
return url
4371

72+
def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
73+
warnings.warn(
74+
"endpoints.broadcast_url is deprecated (use endpoints.get_broadcast_url instead).",
75+
DeprecationWarning,
76+
stacklevel=2,
77+
)
78+
return self.get_broadcast_url(broadcast_id, stop, layout)
79+
4480
def force_disconnect_url(self, session_id, connection_id):
4581
""" this method returns the force disconnect url endpoint """
4682
url = (

opentok/opentok.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import xml.dom.minidom as xmldom # create_session
1313
from jose import jwt # _create_jwt_auth_header
1414
import random # _create_jwt_auth_header
15+
import warnings # Native. Used for notifying deprecations
1516

1617
# compat
1718
from six.moves.urllib.parse import urlencode
@@ -422,12 +423,28 @@ def get_headers(self):
422423
"X-OPENTOK-AUTH": self._create_jwt_auth_header(),
423424
}
424425

426+
def headers(self):
427+
warnings.warn(
428+
"opentok.headers is deprecated (use opentok.get_headers instead).",
429+
DeprecationWarning,
430+
stacklevel=2,
431+
)
432+
return self.get_headers()
433+
425434
def get_json_headers(self):
426435
"""For internal use."""
427436
result = self.get_headers()
428437
result["Content-Type"] = "application/json"
429438
return result
430439

440+
def json_headers(self):
441+
warnings.warn(
442+
"opentok.json_headers is deprecated (use opentok.get_json_headers instead).",
443+
DeprecationWarning,
444+
stacklevel=2,
445+
)
446+
return self.get_json_headers()
447+
431448
def start_archive(
432449
self,
433450
session_id,
@@ -690,6 +707,14 @@ def send_signal(self, session_id, payload, connection_id=None):
690707
else:
691708
raise RequestError("An unexpected error occurred", response.status_code)
692709

710+
def signal(self, session_id, payload, connection_id=None):
711+
warnings.warn(
712+
"opentok.signal is deprecated (use opentok.send_signal instead).",
713+
DeprecationWarning,
714+
stacklevel=2,
715+
)
716+
self.send_signal(session_id, payload, connection_id)
717+
693718
def get_stream(self, session_id, stream_id):
694719
"""
695720
Returns an Stream object that contains information of an OpenTok stream:

0 commit comments

Comments
 (0)