@@ -864,28 +864,29 @@ def add_archive_stream(
864
864
)
865
865
866
866
if response :
867
- return Archive (self , response .json ())
868
- elif response .status_code == 403 :
869
- raise AuthError ()
870
- elif response .status_code == 400 :
871
- """
872
- The HTTP response has a 400 status code in the following cases:
873
- You do not pass in a session ID or you pass in an invalid session ID.
874
- No clients are actively connected to the OpenTok session.
875
- You specify an invalid resolution value.
876
- The outputMode property is set to "individual" and you set the resolution property and (which is not supported in individual stream archives).
877
- """
878
- raise RequestError (response .json ().get ("message" ))
879
- elif response .status_code == 404 :
880
- raise NotFoundError ("Archive or Stream not found" )
881
- elif response .status_code == 405 :
882
- raise ArchiveStreamModeError (
883
- "Your archive is configured with a streamMode that does not support stream manipulation."
884
- )
885
- elif response .status_code == 409 :
886
- raise ArchiveError (response .json ().get ("message" ))
867
+ if response .status_code == 204 :
868
+ return None
869
+ elif response .status_code == 403 :
870
+ raise AuthError ()
871
+ elif response .status_code == 400 :
872
+ """
873
+ The HTTP response has a 400 status code in the following cases:
874
+ You do not pass in a session ID or you pass in an invalid session ID.
875
+ No clients are actively connected to the OpenTok session.
876
+ You specify an invalid resolution value.
877
+ The outputMode property is set to "individual" and you set the resolution property and (which is not supported in individual stream archives).
878
+ """
879
+ raise RequestError (response .json ().get ("message" ))
880
+ elif response .status_code == 404 :
881
+ raise NotFoundError ("Archive or Stream not found" )
882
+ elif response .status_code == 405 :
883
+ raise ArchiveStreamModeError (
884
+ "Your archive is configured with a streamMode that does not support stream manipulation."
885
+ )
886
+ elif response .status_code == 409 :
887
+ raise ArchiveError (response .json ().get ("message" ))
887
888
else :
888
- raise RequestError ("An unexpected error occurred" , response .status_code )
889
+ raise RequestError ("An unexpected error occurred. " , response .status_code )
889
890
890
891
def remove_archive_stream (
891
892
self , archive_id : str , stream_id : str
@@ -910,28 +911,29 @@ def remove_archive_stream(
910
911
)
911
912
912
913
if response :
913
- return Archive (self , response .json ())
914
- elif response .status_code == 403 :
915
- raise AuthError ()
916
- elif response .status_code == 400 :
917
- """
918
- The HTTP response has a 400 status code in the following cases:
919
- You do not pass in a session ID or you pass in an invalid session ID.
920
- No clients are actively connected to the OpenTok session.
921
- You specify an invalid resolution value.
922
- The outputMode property is set to "individual" and you set the resolution property and (which is not supported in individual stream archives).
923
- """
924
- raise RequestError (response .json ().get ("message" ))
925
- elif response .status_code == 404 :
926
- raise NotFoundError ("Archive or Stream not found" )
927
- elif response .status_code == 405 :
928
- raise ArchiveStreamModeError (
929
- "Your archive is configured with a streamMode that does not support stream manipulation."
930
- )
931
- elif response .status_code == 409 :
932
- raise ArchiveError (response .json ().get ("message" ))
914
+ if response .status_code == 204 :
915
+ return None
916
+ elif response .status_code == 403 :
917
+ raise AuthError ()
918
+ elif response .status_code == 400 :
919
+ """
920
+ The HTTP response has a 400 status code in the following cases:
921
+ You do not pass in a session ID or you pass in an invalid session ID.
922
+ No clients are actively connected to the OpenTok session.
923
+ You specify an invalid resolution value.
924
+ The outputMode property is set to "individual" and you set the resolution property and (which is not supported in individual stream archives).
925
+ """
926
+ raise RequestError (response .json ().get ("message" ))
927
+ elif response .status_code == 404 :
928
+ raise NotFoundError ("Archive or Stream not found" )
929
+ elif response .status_code == 405 :
930
+ raise ArchiveStreamModeError (
931
+ "Your archive is configured with a streamMode that does not support stream manipulation."
932
+ )
933
+ elif response .status_code == 409 :
934
+ raise ArchiveError (response .json ().get ("message" ))
933
935
else :
934
- raise RequestError ("An unexpected error occurred" , response .status_code )
936
+ raise RequestError ("An unexpected error occurred. " , response .status_code )
935
937
936
938
def send_signal (self , session_id , payload , connection_id = None ):
937
939
"""
@@ -964,26 +966,27 @@ def send_signal(self, session_id, payload, connection_id=None):
964
966
timeout = self .timeout ,
965
967
)
966
968
967
- if response .status_code == 204 :
968
- pass
969
- elif response .status_code == 400 :
970
- raise SignalingError (
971
- "One of the signal properties - data, type, sessionId or connectionId - is invalid."
972
- )
973
- elif response .status_code == 403 :
974
- raise AuthError (
975
- "You are not authorized to send the signal. Check your authentication credentials."
976
- )
977
- elif response .status_code == 404 :
978
- raise SignalingError (
979
- "The client specified by the connectionId property is not connected to the session."
980
- )
981
- elif response .status_code == 413 :
982
- raise SignalingError (
983
- "The type string exceeds the maximum length (128 bytes), or the data string exceeds the maximum size (8 kB)."
984
- )
969
+ if response :
970
+ if response .status_code == 204 :
971
+ return None
972
+ elif response .status_code == 400 :
973
+ raise SignalingError (
974
+ "One of the signal properties - data, type, sessionId or connectionId - is invalid."
975
+ )
976
+ elif response .status_code == 403 :
977
+ raise AuthError (
978
+ "You are not authorized to send the signal. Check your authentication credentials."
979
+ )
980
+ elif response .status_code == 404 :
981
+ raise SignalingError (
982
+ "The client specified by the connectionId property is not connected to the session."
983
+ )
984
+ elif response .status_code == 413 :
985
+ raise SignalingError (
986
+ "The type string exceeds the maximum length (128 bytes), or the data string exceeds the maximum size (8 kB)."
987
+ )
985
988
else :
986
- raise RequestError ("An unexpected error occurred" , response .status_code )
989
+ raise RequestError ("An unexpected error occurred. " , response .status_code )
987
990
988
991
def signal (self , session_id , payload , connection_id = None ):
989
992
warnings .warn (
@@ -1559,24 +1562,25 @@ def add_broadcast_stream(
1559
1562
)
1560
1563
1561
1564
if response :
1562
- return Broadcast (response .json ())
1563
- elif response .status_code == 400 :
1564
- raise BroadcastError (
1565
- "Invalid request. This response may indicate that data in your request data is "
1566
- "invalid JSON. It may also indicate that you passed in invalid layout options. "
1567
- "Or you have exceeded the limit of five simultaneous RTMP streams for an OpenTok "
1568
- "session. Or you specified and invalid resolution."
1569
- )
1570
- elif response .status_code == 403 :
1571
- raise AuthError ("Authentication error." )
1572
- elif response .status_code == 405 :
1573
- raise BroadcastStreamModeError (
1574
- "Your broadcast is configured with a streamMode that does not support stream manipulation."
1575
- )
1576
- elif response .status_code == 409 :
1577
- raise BroadcastError ("The broadcast has already started for the session." )
1565
+ if response .status_code == 204 :
1566
+ return None
1567
+ elif response .status_code == 400 :
1568
+ raise BroadcastError (
1569
+ "Invalid request. This response may indicate that data in your request data is "
1570
+ "invalid JSON. It may also indicate that you passed in invalid layout options. "
1571
+ "Or you have exceeded the limit of five simultaneous RTMP streams for an OpenTok "
1572
+ "session. Or you specified and invalid resolution."
1573
+ )
1574
+ elif response .status_code == 403 :
1575
+ raise AuthError ("Authentication error." )
1576
+ elif response .status_code == 405 :
1577
+ raise BroadcastStreamModeError (
1578
+ "Your broadcast is configured with a streamMode that does not support stream manipulation."
1579
+ )
1580
+ elif response .status_code == 409 :
1581
+ raise BroadcastError ("The broadcast has already started for the session." )
1578
1582
else :
1579
- raise RequestError ("OpenTok server error." , response .status_code )
1583
+ raise RequestError ("An unexpected error occurred ." , response .status_code )
1580
1584
1581
1585
def remove_broadcast_stream (
1582
1586
self , broadcast_id : str , stream_id : str
@@ -1601,22 +1605,23 @@ def remove_broadcast_stream(
1601
1605
)
1602
1606
1603
1607
if response :
1604
- return Broadcast (response .json ())
1605
- elif response .status_code == 400 :
1606
- raise BroadcastError (
1607
- "Invalid request. This response may indicate that data in your request data is "
1608
- "invalid JSON. It may also indicate that you passed in invalid layout options. "
1609
- "Or you have exceeded the limit of five simultaneous RTMP streams for an OpenTok "
1610
- "session. Or you specified and invalid resolution."
1611
- )
1612
- elif response .status_code == 403 :
1613
- raise AuthError ("Authentication error." )
1614
- elif response .status_code == 405 :
1615
- raise BroadcastStreamModeError (
1616
- "Your broadcast is configured with a streamMode that does not support stream manipulation."
1617
- )
1618
- elif response .status_code == 409 :
1619
- raise BroadcastError ("The broadcast has already started for the session." )
1608
+ if response .status_code == 204 :
1609
+ return None
1610
+ elif response .status_code == 400 :
1611
+ raise BroadcastError (
1612
+ "Invalid request. This response may indicate that data in your request data is "
1613
+ "invalid JSON. It may also indicate that you passed in invalid layout options. "
1614
+ "Or you have exceeded the limit of five simultaneous RTMP streams for an OpenTok "
1615
+ "session. Or you specified and invalid resolution."
1616
+ )
1617
+ elif response .status_code == 403 :
1618
+ raise AuthError ("Authentication error." )
1619
+ elif response .status_code == 405 :
1620
+ raise BroadcastStreamModeError (
1621
+ "Your broadcast is configured with a streamMode that does not support stream manipulation."
1622
+ )
1623
+ elif response .status_code == 409 :
1624
+ raise BroadcastError ("The broadcast has already started for the session." )
1620
1625
else :
1621
1626
raise RequestError ("OpenTok server error." , response .status_code )
1622
1627
0 commit comments