ket.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- encoding:utf-8 -*-
  2. from kscore.session import get_session
  3. import time
  4. class KetClient:
  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 Preset(self,param):
  13. return self.client.preset(**param)
  14. def UpdatePreset(self,param):
  15. return self.client.update_preset(**param)
  16. def GetPresetList(self,App='live',UniqName=''):
  17. return self.client.get_preset_list(App=App,UniqName=UniqName)
  18. def GetPresetDetail(self,App='live',UniqName='',Preset=''):
  19. return self.client.get_preset_detail(App=App,UniqName=UniqName,Preset=Preset)
  20. def DelPreset(self,App='live',UniqName='',Preset=''):
  21. return self.client.del_preset(App=App,UniqName=UniqName,Preset=Preset)
  22. def StartStreamPull(self,param):
  23. return self.client.start_stream_pull(**param)
  24. def StopStreamPull(self,param):
  25. return self.client.stop_stream_pull(**param)
  26. def GetStreamTranList(self,App='live',UniqName='',StreamID='',OutPull=-1):
  27. return self.client.get_stream_tran_list(App=App,UniqName=UniqName,StreamID=StreamID,OutPull=OutPull)
  28. def GetQuotaUsed(self,UniqName=''):
  29. return self.client.get_quota_used(UniqName=UniqName)
  30. def StartLoop(self,param):
  31. return self.client.start_loop(**param)
  32. def StopLoop(self,param):
  33. return self.client.stop_loop(**param)
  34. def UpdateLoop(self,param):
  35. return self.client.update_loop(**param)
  36. def GetLoopList(self,App='live',UniqName='',StreamID=''):
  37. return self.client.get_loop_list(App=App,UniqName=UniqName,StreamID=StreamID)
  38. def GetLiveTransDuration(self,StartUnixTime,EndUnixTime,UniqName='',Granularity=5,ResultType=1):
  39. return self.client.get_live_trans_duration(UniqName=UniqName,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime,Granularity=Granularity,ResultType=ResultType)
  40. def CreateDirectorTask(self,param):
  41. return self.client.create_director_task(**param)
  42. def UpdateDirectorTask(self,param):
  43. return self.client.update_director_task(**param)
  44. def QueryDirectorTask(self,App='live',UniqName='',TaskID=''):
  45. return self.client.query_director_task(App=App, UniqName=UniqName, TaskID=TaskID)
  46. def DelDirectorTask(self,App='live',UniqName='',TaskID=''):
  47. return self.client.del_director_task(App=App, UniqName=UniqName, TaskID=TaskID)
  48. def getKetClient(service_name,region_name,use_ssl=False,ks_access_key_id=None, ks_secret_access_key=None):
  49. return KetClient(service_name,region_name,use_ssl,ks_access_key_id, ks_secret_access_key)