2
0

kls.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # -*- encoding:utf-8 -*-
  2. from kscore.session import get_session
  3. import time
  4. class KlsClient:
  5. def __init__(self,service_name,region_name,use_ssl,ks_access_key_id,ks_secret_access_key):
  6. s = get_session()
  7. if ks_access_key_id != None and ks_secret_access_key != None:
  8. self.client = s.create_client(service_name, region_name, use_ssl = use_ssl,
  9. ks_access_key_id=ks_access_key_id, ks_secret_access_key=ks_secret_access_key)
  10. else:
  11. self.client = s.create_client(service_name, region_name, use_ssl = use_ssl)
  12. def CreateRecordTask(self,param):
  13. return self.client.create_record_task(**param)
  14. def CancelRecordTask(self,param):
  15. return self.client.cancel_record_task(**param)
  16. def StartStreamRecord(self,param):
  17. return self.client.start_stream_record(**param)
  18. def StopStreamRecord(self,param):
  19. return self.client.stop_stream_record(**param)
  20. def ListRecordingTasks(self,UniqueName="",App="",Pubdomain="",Stream="",RecType=0,Limit=1,Marker=1,OrderTime=0,RecStatusType=0):
  21. return self.client.list_recording_tasks(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,RecType=RecType,Limit=Limit,
  22. Marker=Marker,OrderTime=OrderTime,RecStatusType=RecStatusType)
  23. def ListHistoryRecordTasks(self,UniqueName="",App="",Pubdomain="",Stream="",RecType=0,Limit=1,Marker=1,OrderTime=0,StartUnixTime=0,EndUnixTime=0):
  24. return self.client.list_history_record_tasks(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,RecType=RecType,Limit=Limit,
  25. Marker=Marker,OrderTime=OrderTime,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime)
  26. def GetRecordTask(self,RecID=0):
  27. return self.client.get_record_task(RecID = RecID)
  28. def ListRealtimePubStreamsInfo(self,UniqueName="",App="",Pubdomain="",Stream="",Limit=1,Marker=0,OrderTime=0):
  29. return self.client.list_realtime_pub_streams_info(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,Limit=Limit,
  30. Marker=Marker,OrderTime=OrderTime)
  31. def ListHistoryPubStreamsInfo(self,UniqueName="",App="",Pubdomain="",Stream="",Limit=1,Marker=0,OrderTime=0,StartUnixTime=0,EndUnixTime=0):
  32. return self.client.list_history_pub_streams_info(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,Limit=Limit,Marker=Marker,OrderTime=OrderTime,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime)
  33. def ListHistoryPubStreamsErrInfo(self,UniqueName="",App="",Pubdomain="",Stream="",Limit=1,Marker=0,OrderTime=0,StartUnixTime=0,EndUnixTime=0):
  34. return self.client.list_history_pub_streams_err_info(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,Limit=Limit,
  35. Marker=Marker,OrderTime=OrderTime,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime)
  36. def ListStreamDurations(self,UniqueName="",App="",Pubdomain="",Stream="",StartUnixTime=0,EndUnixTime=0):
  37. return self.client.list_stream_durations(UniqueName = UniqueName,App=App,Pubdomain=Pubdomain,Stream=Stream,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime)
  38. def ForbidStream(self,param):
  39. return self.client.forbid_stream(**param)
  40. def ResumeStream(self,param):
  41. return self.client.resume_stream(**param)
  42. def GetBlacklist(self,UniqueName="",App="",Pubdomain=""):
  43. return self.client.get_blacklist(UniqueName = UniqueName,App = App, Pubdomain = Pubdomain)
  44. def CheckBlacklist(self,UniqueName="",App="",Pubdomain="",Stream=""):
  45. return self.client.check_blacklist(UniqueName = UniqueName,App = App, Pubdomain = Pubdomain,Stream = Stream)
  46. def ListRealtimeStreamsInfo(self,param):
  47. return self.client.list_realtime_streams_info(**param)
  48. def KillStreamCache(self,param):
  49. return self.client.kill_stream_cache(**param)
  50. def getKlsClient(service_name,region_name,use_ssl=False,ks_access_key_id=None, ks_secret_access_key=None):
  51. return KlsClient(service_name,region_name,use_ssl,ks_access_key_id, ks_secret_access_key)