12
12
import xml .dom .minidom as xmldom # create_session
13
13
from jose import jwt # _create_jwt_auth_header
14
14
import random # _create_jwt_auth_header
15
+ import logging # logging
15
16
import warnings # Native. Used for notifying deprecations
16
17
18
+
17
19
# compat
18
20
from six .moves .urllib .parse import urlencode
19
21
from six import text_type , u , b , PY3
@@ -77,6 +79,9 @@ class ArchiveModes(Enum):
77
79
"""The session will be automatically archived."""
78
80
79
81
82
+ logger = logging .getLogger ("opentok" )
83
+
84
+
80
85
class OpenTok (object ):
81
86
"""Use this SDK to create tokens and interface with the server-side portion
82
87
of the Opentok API.
@@ -381,6 +386,13 @@ def create_session(
381
386
options [u ("location" )] = location
382
387
383
388
try :
389
+ logger .debug (
390
+ "POST to %r with params %r, headers %r, proxies %r" ,
391
+ self .endpoints .session_url (),
392
+ options ,
393
+ self .headers (),
394
+ self .proxies ,
395
+ )
384
396
response = requests .post (
385
397
self .endpoints .get_session_url (),
386
398
data = options ,
@@ -521,6 +533,14 @@ def start_archive(
521
533
"resolution" : resolution ,
522
534
}
523
535
536
+ logger .debug (
537
+ "POST to %r with params %r, headers %r, proxies %r" ,
538
+ self .endpoints .archive_url (),
539
+ json .dumps (payload ),
540
+ self .json_headers (),
541
+ self .proxies ,
542
+ )
543
+
524
544
response = requests .post (
525
545
self .endpoints .get_archive_url (),
526
546
data = json .dumps (payload ),
@@ -560,6 +580,13 @@ def stop_archive(self, archive_id):
560
580
561
581
:rtype: The Archive object corresponding to the archive being stopped.
562
582
"""
583
+ logger .debug (
584
+ "POST to %r with headers %r, proxies %r" ,
585
+ self .endpoints .archive_url (archive_id ) + "/stop" ,
586
+ self .json_headers (),
587
+ self .proxies ,
588
+ )
589
+
563
590
response = requests .post (
564
591
self .endpoints .get_archive_url (archive_id ) + "/stop" ,
565
592
headers = self .get_json_headers (),
@@ -588,6 +615,13 @@ def delete_archive(self, archive_id):
588
615
589
616
:param String archive_id: The archive ID of the archive to be deleted.
590
617
"""
618
+ logger .debug (
619
+ "DELETE to %r with headers %r, proxies %r" ,
620
+ self .endpoints .archive_url (archive_id ),
621
+ self .json_headers (),
622
+ self .proxies ,
623
+ )
624
+
591
625
response = requests .delete (
592
626
self .endpoints .get_archive_url (archive_id ),
593
627
headers = self .get_json_headers (),
@@ -611,6 +645,13 @@ def get_archive(self, archive_id):
611
645
612
646
:rtype: The Archive object.
613
647
"""
648
+ logger .debug (
649
+ "GET to %r with headers %r, proxies %r" ,
650
+ self .endpoints .archive_url (archive_id ),
651
+ self .json_headers (),
652
+ self .proxies ,
653
+ )
654
+
614
655
response = requests .get (
615
656
self .endpoints .get_archive_url (archive_id ),
616
657
headers = self .get_json_headers (),
@@ -650,6 +691,13 @@ def get_archives(self, offset=None, count=None, session_id=None):
650
691
651
692
endpoint = self .endpoints .get_archive_url () + "?" + urlencode (params )
652
693
694
+ logger .debug (
695
+ "GET to %r with headers %r, proxies %r" ,
696
+ endpoint ,
697
+ self .json_headers (),
698
+ self .proxies ,
699
+ )
700
+
653
701
response = requests .get (
654
702
endpoint ,
655
703
headers = self .get_json_headers (),
@@ -688,6 +736,14 @@ def send_signal(self, session_id, payload, connection_id=None):
688
736
the signal is sent to the specified client. Otherwise, the signal is sent to all clients
689
737
connected to the session
690
738
"""
739
+ logger .debug (
740
+ "POST to %r with params %r, headers %r, proxies %r" ,
741
+ self .endpoints .signaling_url (session_id , connection_id ),
742
+ json .dumps (payload ),
743
+ self .json_headers (),
744
+ self .proxies ,
745
+ )
746
+
691
747
response = requests .post (
692
748
self .endpoints .get_signaling_url (session_id , connection_id ),
693
749
data = json .dumps (payload ),
@@ -735,6 +791,14 @@ def get_stream(self, session_id, stream_id):
735
791
-layoutClassList: It's an array of the layout classes for the stream
736
792
"""
737
793
endpoint = self .endpoints .get_stream_url (session_id , stream_id )
794
+
795
+ logger .debug (
796
+ "GET to %r with headers %r, proxies %r" ,
797
+ endpoint ,
798
+ self .json_headers (),
799
+ self .proxies ,
800
+ )
801
+
738
802
response = requests .get (
739
803
endpoint ,
740
804
headers = self .get_json_headers (),
@@ -765,6 +829,13 @@ def list_streams(self, session_id):
765
829
"""
766
830
endpoint = self .endpoints .get_stream_url (session_id )
767
831
832
+ logger .debug (
833
+ "GET to %r with headers %r, proxies %r" ,
834
+ endpoint ,
835
+ self .json_headers (),
836
+ self .proxies ,
837
+ )
838
+
768
839
response = requests .get (
769
840
endpoint ,
770
841
headers = self .get_json_headers (),
@@ -793,6 +864,14 @@ def force_disconnect(self, session_id, connection_id):
793
864
:param String connection_id: The connection ID of the client that will be disconnected
794
865
"""
795
866
endpoint = self .endpoints .force_disconnect_url (session_id , connection_id )
867
+
868
+ logger .debug (
869
+ "DELETE to %r with headers %r, proxies %r" ,
870
+ endpoint ,
871
+ self .json_headers (),
872
+ self .proxies ,
873
+ )
874
+
796
875
response = requests .delete (
797
876
endpoint ,
798
877
headers = self .get_json_headers (),
@@ -838,6 +917,15 @@ def set_archive_layout(self, archive_id, layout_type, stylesheet=None):
838
917
payload ["stylesheet" ] = stylesheet
839
918
840
919
endpoint = self .endpoints .set_archive_layout_url (archive_id )
920
+
921
+ logger .debug (
922
+ "PUT to %r with params %r, headers %r, proxies %r" ,
923
+ endpoint ,
924
+ json .dumps (payload ),
925
+ self .json_headers (),
926
+ self .proxies ,
927
+ )
928
+
841
929
response = requests .put (
842
930
endpoint ,
843
931
data = json .dumps (payload ),
@@ -909,6 +997,15 @@ def dial(self, session_id, token, sip_uri, options=[]):
909
997
payload ["sip" ]["secure" ] = options ["secure" ]
910
998
911
999
endpoint = self .endpoints .dial_url ()
1000
+
1001
+ logger .debug (
1002
+ "POST to %r with params %r, headers %r, proxies %r" ,
1003
+ endpoint ,
1004
+ json .dumps (payload ),
1005
+ self .json_headers (),
1006
+ self .proxies ,
1007
+ )
1008
+
912
1009
response = requests .post (
913
1010
endpoint ,
914
1011
data = json .dumps (payload ),
@@ -954,6 +1051,15 @@ class names (Strings) to apply to the stream. For example:
954
1051
items_payload = {"items" : payload }
955
1052
956
1053
endpoint = self .endpoints .set_stream_class_lists_url (session_id )
1054
+
1055
+ logger .debug (
1056
+ "PUT to %r with params %r, headers %r, proxies %r" ,
1057
+ endpoint ,
1058
+ json .dumps (items_payload ),
1059
+ self .json_headers (),
1060
+ self .proxies ,
1061
+ )
1062
+
957
1063
response = requests .put (
958
1064
endpoint ,
959
1065
data = json .dumps (items_payload ),
@@ -1016,7 +1122,16 @@ def start_broadcast(self, session_id, options):
1016
1122
1017
1123
payload .update (options )
1018
1124
1019
- endpoint = self .endpoints .get_broadcast_url ()
1125
+ endpoint = self .endpoints .broadcast_url ()
1126
+
1127
+ logger .debug (
1128
+ "POST to %r with params %r, headers %r, proxies %r" ,
1129
+ endpoint ,
1130
+ json .dumps (payload ),
1131
+ self .json_headers (),
1132
+ self .proxies ,
1133
+ )
1134
+
1020
1135
response = requests .post (
1021
1136
endpoint ,
1022
1137
data = json .dumps (payload ),
@@ -1050,7 +1165,16 @@ def stop_broadcast(self, broadcast_id):
1050
1165
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
1051
1166
projectId, createdAt, updatedAt and resolution
1052
1167
"""
1053
- endpoint = self .endpoints .get_broadcast_url (broadcast_id , stop = True )
1168
+
1169
+ endpoint = self .endpoints .broadcast_url (broadcast_id , stop = True )
1170
+
1171
+ logger .debug (
1172
+ "POST to %r with headers %r, proxies %r" ,
1173
+ endpoint ,
1174
+ self .json_headers (),
1175
+ self .proxies ,
1176
+ )
1177
+
1054
1178
response = requests .post (
1055
1179
endpoint ,
1056
1180
headers = self .get_json_headers (),
@@ -1084,7 +1208,16 @@ def get_broadcast(self, broadcast_id):
1084
1208
:rtype A Broadcast object, which contains information of the broadcast: id, sessionId
1085
1209
projectId, createdAt, updatedAt, resolution, broadcastUrls and status
1086
1210
"""
1087
- endpoint = self .endpoints .get_broadcast_url (broadcast_id )
1211
+
1212
+ endpoint = self .endpoints .broadcast_url (broadcast_id )
1213
+
1214
+ logger .debug (
1215
+ "GET to %r with headers %r, proxies %r" ,
1216
+ endpoint ,
1217
+ self .json_headers (),
1218
+ self .proxies ,
1219
+ )
1220
+
1088
1221
response = requests .get (
1089
1222
endpoint ,
1090
1223
headers = self .get_json_headers (),
@@ -1126,7 +1259,16 @@ def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None):
1126
1259
if stylesheet is not None :
1127
1260
payload ["stylesheet" ] = stylesheet
1128
1261
1129
- endpoint = self .endpoints .get_broadcast_url (broadcast_id , layout = True )
1262
+ endpoint = self .endpoints .broadcast_url (broadcast_id , layout = True )
1263
+
1264
+ logger .debug (
1265
+ "PUT to %r with params %r, headers %r, proxies %r" ,
1266
+ endpoint ,
1267
+ json .dumps (payload ),
1268
+ self .json_headers (),
1269
+ self .proxies ,
1270
+ )
1271
+
1130
1272
response = requests .put (
1131
1273
endpoint ,
1132
1274
data = json .dumps (payload ),
0 commit comments