Skip to content

Commit 91510ec

Browse files
authored
Merge pull request #181 from opentok/top-level-entity-naming
top level entity naming
2 parents 4692dc7 + 8192e54 commit 91510ec

18 files changed

+78
-53
lines changed

README.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ Initializing
3939
~~~~~~~~~~~~
4040

4141
Import the package at the top of any file where you will use it. At the very least you will need the
42-
``OpenTok`` class. Then initialize an OpenTok instance with your own API Key and API Secret.
42+
``Client`` class. Then initialize a Client instance with your own API Key and API Secret.
4343

4444
.. code:: python
4545
46-
from opentok import OpenTok
46+
from opentok import Client
4747
48-
opentok = OpenTok(api_key, api_secret)
48+
opentok = Client(api_key, api_secret)
4949
5050
Creating Sessions
5151
~~~~~~~~~~~~~~~~~
@@ -238,7 +238,7 @@ For more information on archiving, see the
238238
Sending Signals
239239
~~~~~~~~~~~~~~~~~~~~~
240240

241-
Once a Session is created, you can send signals to everyone in the session or to a specific connection. You can send a signal by calling the ``signal(session_id, payload)`` method of the ``OpenTok`` class. The ``payload`` parameter is a dictionary used to set the ``type``, ``data`` fields. Ỳou can also call the method with the parameter ``connection_id`` to send a signal to a specific connection ``signal(session_id, data, connection_id)``.
241+
Once a Session is created, you can send signals to everyone in the session or to a specific connection. You can send a signal by calling the ``signal(session_id, payload)`` method of the ``Client`` class. The ``payload`` parameter is a dictionary used to set the ``type``, ``data`` fields. Ỳou can also call the method with the parameter ``connection_id`` to send a signal to a specific connection ``signal(session_id, data, connection_id)``.
242242

243243
.. code:: python
244244
@@ -259,7 +259,7 @@ Once a Session is created, you can send signals to everyone in the session or to
259259
Working with Streams
260260
~~~~~~~~~~~~~~~~~~~~~
261261

262-
You can get information about a stream by calling the `get_stream(session_id, stream_id)` method of the `OpenTok` class.
262+
You can get information about a stream by calling the `get_stream(session_id, stream_id)` method of the `Client` class.
263263

264264
The method returns a Stream object that contains information of an OpenTok stream:
265265

@@ -282,7 +282,7 @@ The method returns a Stream object that contains information of an OpenTok strea
282282
print stream.name #stream name
283283
print stream.layoutClassList #['full']
284284
285-
Also, you can get information about all the streams in a session by calling the `list_streams(session_id)` method of the `OpenTok` class.
285+
Also, you can get information about all the streams in a session by calling the `list_streams(session_id)` method of the `Client` class.
286286

287287
The method returns a StreamList object that contains a list of all the streams
288288

@@ -300,7 +300,7 @@ The method returns a StreamList object that contains a list of all the streams
300300
print stream.name #stream name
301301
print stream.layoutClassList #['full']
302302
303-
You can change the layout classes for streams in a session by calling the `set_stream_class_lists(session_id, stream_list)` method of the `OpenTok` class.
303+
You can change the layout classes for streams in a session by calling the `set_stream_class_lists(session_id, stream_list)` method of the `Client` class.
304304

305305
The layout classes define how the stream is displayed in the layout of a composed OpenTok archive.
306306

@@ -324,7 +324,7 @@ For more information see
324324
Force Disconnect
325325
~~~~~~~~~~~~~~~~~~~~~
326326

327-
Your application server can disconnect a client from an OpenTok session by calling the force_disconnect(session_id, connection_id) method of the OpenTok class, or the force_disconnect(connection_id) method of the Session class.
327+
Your application server can disconnect a client from an OpenTok session by calling the force_disconnect(session_id, connection_id) method of the Client class, or the force_disconnect(connection_id) method of the Session class.
328328

329329
.. code:: python
330330
@@ -473,13 +473,13 @@ For more information about OpenTok live streaming broadcasts, see the
473473

474474
Configuring Timeout
475475
-------
476-
Timeout is passed in the OpenTok constructor:
476+
Timeout is passed in the Client constructor:
477477

478478
``self.timeout = timeout``
479479

480480
In order to configure timeout, first create an instance:
481481

482-
``opentok = OpenTok(...., timeout=value)``
482+
``opentok = Client(...., timeout=value)``
483483

484484
And then proceed to change the value with
485485

@@ -527,7 +527,7 @@ session uses the OpenTok TURN server to relay audio-video streams.
527527

528528
This version of the SDK includes support for working with OpenTok archives.
529529

530-
The OpenTok.create_session() method now includes a media_mode parameter, instead of a p2p parameter.
530+
The Client.create_session() method now includes a media_mode parameter, instead of a p2p parameter.
531531

532532
For details, see the reference documentation at
533533
http://www.tokbox.com/opentok/libraries/server/python/reference/index.html.

opentok/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .opentok import OpenTok, Roles, MediaModes, ArchiveModes
1+
from .opentok import OpenTok, Client, Roles, MediaModes, ArchiveModes
22
from .session import Session
33
from .archives import Archive, ArchiveList, OutputModes
44
from .exceptions import (

opentok/opentok.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class ArchiveModes(Enum):
8282
logger = logging.getLogger("opentok")
8383

8484

85-
class OpenTok(object):
85+
86+
class Client(object):
87+
8688
"""Use this SDK to create tokens and interface with the server-side portion
8789
of the Opentok API.
8890
"""
@@ -1305,3 +1307,25 @@ def _create_jwt_auth_header(self):
13051307
}
13061308

13071309
return jwt.encode(payload, self.api_secret, algorithm="HS256")
1310+
1311+
class OpenTok(Client):
1312+
def __init__(
1313+
self,
1314+
api_key,
1315+
api_secret,
1316+
api_url="https://api.opentok.com",
1317+
timeout=None,
1318+
app_version=None,
1319+
):
1320+
warnings.warn(
1321+
"OpenTok class is deprecated (Use Client class instead)",
1322+
DeprecationWarning,
1323+
stacklevel=2,
1324+
)
1325+
super(OpenTok, self).__init__(
1326+
api_key,
1327+
api_secret,
1328+
api_url=api_url,
1329+
timeout=timeout,
1330+
app_version=app_version
1331+
)

sample/Archiving/archiving.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flask import Flask, render_template, request, redirect, url_for
2-
from opentok import OpenTok, MediaModes, OutputModes
2+
from opentok import Client, MediaModes, OutputModes
33
from email.utils import formatdate
44
import os, time
55

@@ -10,7 +10,7 @@
1010
raise Exception("You must define API_KEY and API_SECRET environment variables")
1111

1212
app = Flask(__name__)
13-
opentok = OpenTok(api_key, api_secret)
13+
opentok = Client(api_key, api_secret)
1414
session = opentok.create_session(media_mode=MediaModes.routed)
1515

1616

sample/HelloWorld/helloworld.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flask import Flask, render_template
2-
from opentok import OpenTok
2+
from opentok import Client
33
import os
44

55
try:
@@ -9,7 +9,7 @@
99
raise Exception("You must define API_KEY and API_SECRET environment variables")
1010

1111
app = Flask(__name__)
12-
opentok = OpenTok(api_key, api_secret)
12+
opentok = Client(api_key, api_secret)
1313
session = opentok.create_session()
1414

1515

tests/test_archive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import pytz
1010
from .validate_jwt import validate_jwt_header
1111

12-
from opentok import OpenTok, Archive, __version__, OutputModes
12+
from opentok import Client, Archive, __version__, OutputModes
1313

1414

1515
class OpenTokArchiveTest(unittest.TestCase):
1616
def setUp(self):
1717
self.api_key = u("123456")
1818
self.api_secret = u("1234567890abcdef1234567890abcdef1234567890")
19-
self.opentok = OpenTok(self.api_key, self.api_secret)
19+
self.opentok = Client(self.api_key, self.api_secret)
2020

2121
@httpretty.activate
2222
def test_stop_archive(self):

tests/test_archive_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .validate_jwt import validate_jwt_header
1111

1212
from opentok import (
13-
OpenTok,
13+
Client,
1414
Archive,
1515
ArchiveList,
1616
OutputModes,
@@ -25,7 +25,7 @@ def setUp(self):
2525
self.api_key = u("123456")
2626
self.api_secret = u("1234567890abcdef1234567890abcdef1234567890")
2727
self.session_id = u("SESSIONID")
28-
self.opentok = OpenTok(self.api_key, self.api_secret)
28+
self.opentok = Client(self.api_key, self.api_secret)
2929

3030
@httpretty.activate
3131
def test_start_archive(self):

tests/test_broadcast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
from six import u
66
from expects import *
7-
from opentok import OpenTok, Broadcast, __version__, BroadcastError
7+
from opentok import Client, Broadcast, __version__, BroadcastError
88
from .validate_jwt import validate_jwt_header
99

1010

1111
class OpenTokBroadcastTest(unittest.TestCase):
1212
def setUp(self):
1313
self.api_key = u("123456")
1414
self.api_secret = u("1234567890abcdef1234567890abcdef1234567890")
15-
self.opentok = OpenTok(self.api_key, self.api_secret)
15+
self.opentok = Client(self.api_key, self.api_secret)
1616
self.session_id = u("2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ-TjMzfn4")
1717

1818
@httpretty.activate

tests/test_force_disconnect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from expects import *
44
import httpretty
55

6-
from opentok import OpenTok, __version__, AuthError, ForceDisconnectError
6+
from opentok import Client, __version__, AuthError, ForceDisconnectError
77
from .validate_jwt import validate_jwt_header
88

99

@@ -13,13 +13,13 @@ class OpenTokForceDisconnectTest(unittest.TestCase):
1313
def setUp(self):
1414
self.api_key = u("123456")
1515
self.api_secret = u("1234567890abcdef1234567890abcdef1234567890")
16-
self.opentok = OpenTok(self.api_key, self.api_secret)
16+
self.opentok = Client(self.api_key, self.api_secret)
1717
self.session_id = u("SESSIONID")
1818
self.connection_id = u("CONNECTIONID")
1919

2020
@httpretty.activate
2121
def test_force_disconnect(self):
22-
""" Method to test force disconnect functionality using an OpenTok instance """
22+
""" Method to test force disconnect functionality using an Client instance """
2323

2424
httpretty.register_uri(
2525
httpretty.DELETE,

tests/test_getter_setter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from nose.tools import raises
44
from expects import *
55

6-
from opentok import OpenTok, __version__
6+
from opentok import Client, __version__
77
import time
88

99

@@ -14,7 +14,8 @@ def setUp(self):
1414
self.session_id = u(
1515
"1_MX4xMjM0NTZ-flNhdCBNYXIgMTUgMTQ6NDI6MjMgUERUIDIwMTR-MC40OTAxMzAyNX4"
1616
)
17-
self.opentok = OpenTok(self.api_key, self.api_secret)
17+
18+
self.opentok = Client(self.api_key, self.api_secret)
1819

1920
def test_getset_jwt_livetime(self):
2021
livetime = self.opentok.jwt_livetime

0 commit comments

Comments
 (0)