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
16
17
# compat
17
18
from six .moves .urllib .parse import urlencode
@@ -76,6 +77,9 @@ class ArchiveModes(Enum):
76
77
"""The session will be automatically archived."""
77
78
78
79
80
+ logger = logging .getLogger ("opentok" )
81
+
82
+
79
83
class OpenTok (object ):
80
84
"""Use this SDK to create tokens and interface with the server-side portion
81
85
of the Opentok API.
@@ -370,6 +374,13 @@ def create_session(
370
374
options [u ("location" )] = location
371
375
372
376
try :
377
+ logger .debug (
378
+ "POST to %r with params %r, headers %r, proxies %r" ,
379
+ self .endpoints .session_url (),
380
+ options ,
381
+ self .headers (),
382
+ self .proxies ,
383
+ )
373
384
response = requests .post (
374
385
self .endpoints .session_url (),
375
386
data = options ,
@@ -494,6 +505,14 @@ def start_archive(
494
505
"resolution" : resolution ,
495
506
}
496
507
508
+ logger .debug (
509
+ "POST to %r with params %r, headers %r, proxies %r" ,
510
+ self .endpoints .archive_url (),
511
+ json .dumps (payload ),
512
+ self .json_headers (),
513
+ self .proxies ,
514
+ )
515
+
497
516
response = requests .post (
498
517
self .endpoints .archive_url (),
499
518
data = json .dumps (payload ),
@@ -533,6 +552,13 @@ def stop_archive(self, archive_id):
533
552
534
553
:rtype: The Archive object corresponding to the archive being stopped.
535
554
"""
555
+ logger .debug (
556
+ "POST to %r with headers %r, proxies %r" ,
557
+ self .endpoints .archive_url (archive_id ) + "/stop" ,
558
+ self .json_headers (),
559
+ self .proxies ,
560
+ )
561
+
536
562
response = requests .post (
537
563
self .endpoints .archive_url (archive_id ) + "/stop" ,
538
564
headers = self .json_headers (),
@@ -561,6 +587,13 @@ def delete_archive(self, archive_id):
561
587
562
588
:param String archive_id: The archive ID of the archive to be deleted.
563
589
"""
590
+ logger .debug (
591
+ "DELETE to %r with headers %r, proxies %r" ,
592
+ self .endpoints .archive_url (archive_id ),
593
+ self .json_headers (),
594
+ self .proxies ,
595
+ )
596
+
564
597
response = requests .delete (
565
598
self .endpoints .archive_url (archive_id ),
566
599
headers = self .json_headers (),
@@ -584,6 +617,13 @@ def get_archive(self, archive_id):
584
617
585
618
:rtype: The Archive object.
586
619
"""
620
+ logger .debug (
621
+ "GET to %r with headers %r, proxies %r" ,
622
+ self .endpoints .archive_url (archive_id ),
623
+ self .json_headers (),
624
+ self .proxies ,
625
+ )
626
+
587
627
response = requests .get (
588
628
self .endpoints .archive_url (archive_id ),
589
629
headers = self .json_headers (),
@@ -623,6 +663,13 @@ def get_archives(self, offset=None, count=None, session_id=None):
623
663
624
664
endpoint = self .endpoints .archive_url () + "?" + urlencode (params )
625
665
666
+ logger .debug (
667
+ "GET to %r with headers %r, proxies %r" ,
668
+ endpoint ,
669
+ self .json_headers (),
670
+ self .proxies ,
671
+ )
672
+
626
673
response = requests .get (
627
674
endpoint ,
628
675
headers = self .json_headers (),
@@ -661,6 +708,14 @@ def signal(self, session_id, payload, connection_id=None):
661
708
the signal is sent to the specified client. Otherwise, the signal is sent to all clients
662
709
connected to the session
663
710
"""
711
+ logger .debug (
712
+ "POST to %r with params %r, headers %r, proxies %r" ,
713
+ self .endpoints .signaling_url (session_id , connection_id ),
714
+ json .dumps (payload ),
715
+ self .json_headers (),
716
+ self .proxies ,
717
+ )
718
+
664
719
response = requests .post (
665
720
self .endpoints .signaling_url (session_id , connection_id ),
666
721
data = json .dumps (payload ),
@@ -700,6 +755,14 @@ def get_stream(self, session_id, stream_id):
700
755
-layoutClassList: It's an array of the layout classes for the stream
701
756
"""
702
757
endpoint = self .endpoints .get_stream_url (session_id , stream_id )
758
+
759
+ logger .debug (
760
+ "GET to %r with headers %r, proxies %r" ,
761
+ endpoint ,
762
+ self .json_headers (),
763
+ self .proxies ,
764
+ )
765
+
703
766
response = requests .get (
704
767
endpoint ,
705
768
headers = self .json_headers (),
@@ -730,6 +793,13 @@ def list_streams(self, session_id):
730
793
"""
731
794
endpoint = self .endpoints .get_stream_url (session_id )
732
795
796
+ logger .debug (
797
+ "GET to %r with headers %r, proxies %r" ,
798
+ endpoint ,
799
+ self .json_headers (),
800
+ self .proxies ,
801
+ )
802
+
733
803
response = requests .get (
734
804
endpoint ,
735
805
headers = self .json_headers (),
@@ -758,6 +828,14 @@ def force_disconnect(self, session_id, connection_id):
758
828
:param String connection_id: The connection ID of the client that will be disconnected
759
829
"""
760
830
endpoint = self .endpoints .force_disconnect_url (session_id , connection_id )
831
+
832
+ logger .debug (
833
+ "DELETE to %r with headers %r, proxies %r" ,
834
+ endpoint ,
835
+ self .json_headers (),
836
+ self .proxies ,
837
+ )
838
+
761
839
response = requests .delete (
762
840
endpoint ,
763
841
headers = self .json_headers (),
@@ -803,6 +881,15 @@ def set_archive_layout(self, archive_id, layout_type, stylesheet=None):
803
881
payload ["stylesheet" ] = stylesheet
804
882
805
883
endpoint = self .endpoints .set_archive_layout_url (archive_id )
884
+
885
+ logger .debug (
886
+ "PUT to %r with params %r, headers %r, proxies %r" ,
887
+ endpoint ,
888
+ json .dumps (payload ),
889
+ self .json_headers (),
890
+ self .proxies ,
891
+ )
892
+
806
893
response = requests .put (
807
894
endpoint ,
808
895
data = json .dumps (payload ),
@@ -874,6 +961,15 @@ def dial(self, session_id, token, sip_uri, options=[]):
874
961
payload ["sip" ]["secure" ] = options ["secure" ]
875
962
876
963
endpoint = self .endpoints .dial_url ()
964
+
965
+ logger .debug (
966
+ "POST to %r with params %r, headers %r, proxies %r" ,
967
+ endpoint ,
968
+ json .dumps (payload ),
969
+ self .json_headers (),
970
+ self .proxies ,
971
+ )
972
+
877
973
response = requests .post (
878
974
endpoint ,
879
975
data = json .dumps (payload ),
@@ -919,6 +1015,15 @@ class names (Strings) to apply to the stream. For example:
919
1015
items_payload = {"items" : payload }
920
1016
921
1017
endpoint = self .endpoints .set_stream_class_lists_url (session_id )
1018
+
1019
+ logger .debug (
1020
+ "PUT to %r with params %r, headers %r, proxies %r" ,
1021
+ endpoint ,
1022
+ json .dumps (items_payload ),
1023
+ self .json_headers (),
1024
+ self .proxies ,
1025
+ )
1026
+
922
1027
response = requests .put (
923
1028
endpoint ,
924
1029
data = json .dumps (items_payload ),
@@ -982,6 +1087,15 @@ def start_broadcast(self, session_id, options):
982
1087
payload .update (options )
983
1088
984
1089
endpoint = self .endpoints .broadcast_url ()
1090
+
1091
+ logger .debug (
1092
+ "POST to %r with params %r, headers %r, proxies %r" ,
1093
+ endpoint ,
1094
+ json .dumps (payload ),
1095
+ self .json_headers (),
1096
+ self .proxies ,
1097
+ )
1098
+
985
1099
response = requests .post (
986
1100
endpoint ,
987
1101
data = json .dumps (payload ),
@@ -1016,6 +1130,14 @@ def stop_broadcast(self, broadcast_id):
1016
1130
projectId, createdAt, updatedAt and resolution
1017
1131
"""
1018
1132
endpoint = self .endpoints .broadcast_url (broadcast_id , stop = True )
1133
+
1134
+ logger .debug (
1135
+ "POST to %r with headers %r, proxies %r" ,
1136
+ endpoint ,
1137
+ self .json_headers (),
1138
+ self .proxies ,
1139
+ )
1140
+
1019
1141
response = requests .post (
1020
1142
endpoint ,
1021
1143
headers = self .json_headers (),
@@ -1050,6 +1172,14 @@ def get_broadcast(self, broadcast_id):
1050
1172
projectId, createdAt, updatedAt, resolution, broadcastUrls and status
1051
1173
"""
1052
1174
endpoint = self .endpoints .broadcast_url (broadcast_id )
1175
+
1176
+ logger .debug (
1177
+ "GET to %r with headers %r, proxies %r" ,
1178
+ endpoint ,
1179
+ self .json_headers (),
1180
+ self .proxies ,
1181
+ )
1182
+
1053
1183
response = requests .get (
1054
1184
endpoint ,
1055
1185
headers = self .json_headers (),
@@ -1092,6 +1222,15 @@ def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None):
1092
1222
payload ["stylesheet" ] = stylesheet
1093
1223
1094
1224
endpoint = self .endpoints .broadcast_url (broadcast_id , layout = True )
1225
+
1226
+ logger .debug (
1227
+ "PUT to %r with params %r, headers %r, proxies %r" ,
1228
+ endpoint ,
1229
+ json .dumps (payload ),
1230
+ self .json_headers (),
1231
+ self .proxies ,
1232
+ )
1233
+
1095
1234
response = requests .put (
1096
1235
endpoint ,
1097
1236
data = json .dumps (payload ),
0 commit comments