@@ -41,8 +41,9 @@ Initializing
41
41
~~~~~~~~~~~~
42
42
43
43
Import the package at the top of any file where you will use it. At the very least you will need the
44
- ``OpenTok `` class. Then initialize an OpenTok instance with your own API Key and API Secret.::
44
+ ``OpenTok `` class. Then initialize an OpenTok instance with your own API Key and API Secret.
45
45
46
+ .. code :: python
46
47
from opentok import OpenTok
47
48
48
49
opentok = OpenTok(api_key, api_secret)
@@ -53,8 +54,9 @@ Creating Sessions
53
54
The create an OpenTok Session, use the ``opentok.create_session() `` method. There are two optional
54
55
keyword parameters for this method: ``location `` which can be set to a string containing an IP
55
56
address, and ``p2p `` which is a boolean. This method returns a ``Session `` object. Its
56
- ``session_id `` attribute is useful when saving to a persistent store (e.g. database).::
57
+ ``session_id `` attribute is useful when saving to a persistent store (e.g. database).
57
58
59
+ .. code :: python
58
60
# Just a plain Session
59
61
session = opentok.create_session()
60
62
# A p2p Session
@@ -71,8 +73,9 @@ Generating Tokens
71
73
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
72
74
You can generate a token either by calling the ``opentok.generate_token(session_id) `` method or by
73
75
calling the ``session.generate_token() `` method on a ``Session `` instance after creating it. There
74
- is a set of optional keyword parameters: ``role ``, ``expire_time ``, and ``data ``.::
76
+ is a set of optional keyword parameters: ``role ``, ``expire_time ``, and ``data ``.
75
77
78
+ .. code :: python
76
79
# Generate a Token from just a session_id (fetched from a database)
77
80
token = opentok.generate_token(session_id)
78
81
# Generate a Token by calling the method on the Session (returned from create_session)
@@ -90,29 +93,33 @@ Working with Archives
90
93
You can start the recording of an OpenTok Session using the ``opentok.start_archive(session_id) ``
91
94
method. This method takes an optional keyword argument ``name `` to assign a name to the archive.
92
95
This method will return an ``Archive `` instance. Note that you can only start an Archive on
93
- a Session that has clients connection.::
96
+ a Session that has clients connection.
94
97
98
+ .. code :: python
95
99
archive = opentok.start_archive(session_id, name = u ' Important Presentation' )
96
100
97
101
# Store this archive_id in the database
98
102
archive_id = archive.id
99
103
100
104
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id) ``
101
- method. You can also do this using the ``archive.stop() `` method of an ``Archive `` instance.::
105
+ method. You can also do this using the ``archive.stop() `` method of an ``Archive `` instance.
102
106
107
+ .. code :: python
103
108
# Stop an Archive from an archive_id (fetched from database)
104
109
opentok.stop_archive(archive_id)
105
110
# Stop an Archive from an instance (returned from opentok.start_archive)
106
111
archive.stop()
107
112
108
113
To get an ``Archive `` instance (and all the information about it) from an archive ID, use the
109
- ``opentok.get_archive(archive_id) `` method.::
114
+ ``opentok.get_archive(archive_id) `` method.
110
115
116
+ .. code :: python
111
117
archive = opentok.get_archive(archive_id)
112
118
113
119
To delete an Archive, you can call the ``opentok.delete_archive(archive_id) `` method or the
114
- ``archive.delete() `` method of an ``Archive `` instance.::
120
+ ``archive.delete() `` method of an ``Archive `` instance.
115
121
122
+ .. code :: python
116
123
# Delete an Archive from an archive ID (fetched from database)
117
124
opentok.delete_archive(archive_id)
118
125
# Delete an Archive from an Archive instance (returned from opentok.start_archive or
@@ -122,8 +129,9 @@ To delete an Archive, you can call the ``opentok.delete_archive(archive_id)`` me
122
129
You can also get a list of all the Archives you've created (up to 1000) with your API Key. This is
123
130
done using the ``opentok.list_archives() `` method. There are two optional keyword parameters:
124
131
``count `` and ``offset ``; they can help you paginate through the results. This method returns an
125
- instance of the ``ArchiveList `` class.::
132
+ instance of the ``ArchiveList `` class.
126
133
134
+ .. code :: python
127
135
archive_list = opentok.list_archive()
128
136
129
137
# Get a specific Archive from the list
0 commit comments