Skip to content

Commit dd3f30c

Browse files
author
yangxueyi
committed
解决冲突
2 parents 55c9524 + 2de7a10 commit dd3f30c

File tree

8 files changed

+290
-6
lines changed

8 files changed

+290
-6
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Install 安装
1212
+ pip install ksc-sdk-python
1313

1414
+ github 安装
15-
+ 通过 `GitHub <https://github.com/liuyichen/kscore>`__ 下载
16-
+ 进入`kscore`目录通过命令 python setup.py install 安装
15+
+ 通过 `GitHub <https://github.com/KscSDK/ksc-sdk-python>`__ 下载
16+
+ 通过命令 python setup.py install 安装
1717

1818
----------------
1919
Config 配置

examples/cdn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@
735735
EndTime string 查询结束时间,格式yyyy-MM-dd,开始时间和结束时间均不指定时,默认是当天
736736
TaskId string 支持按任务ID查询,只允许输入单个任务ID
737737
Urls Url[] 需要文件类型预热的Url列表
738+
Type String 任务类别,取值为:refresh,刷新任务;取值为:preload,预热任务
738739
其中url[]为:
739740
Url String 需要提交预热的Url,单条
740741
'''
@@ -749,7 +750,8 @@
749750
"Urls":[
750751
{"Url": "http://test.dxz.ksyun.8686c.com/1.html"},
751752
{"Url": "http://test.dxz.ksyun.8686c.com/abc"}
752-
]
753+
],
754+
"Type":"refresh"
753755
}
754756
'''
755757
# res = client.get_refresh_or_preload_task(**param)
@@ -1167,7 +1169,7 @@
11671169
其中url[]为:
11681170
Url String 需要提交屏蔽/解屏蔽的Url,单条
11691171
'''
1170-
# json格式规则
1172+
# # json格式规则
11711173
# param = {
11721174
# "BlockType":"block",
11731175
# "BlockTime":3600,

examples/ket.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/python
2+
# -*- coding: UTF-8 -*-
3+
from kscore.ket import getKetClient
4+
import json
5+
6+
if __name__ == "__main__":
7+
client = getKetClient("ket", "cn-beijing-6",use_ssl=False)
8+
9+
uniqname = 'mytest'
10+
presetname = 'testpreset00'
11+
appname = 'live'
12+
description = 'just a demo'
13+
presetType = 'avop'
14+
streamid = 'myteststreamid'
15+
outpull = 1
16+
srcurl = "rtmp://qa-ws.test-rtmplive.ks-cdn.com/live/20160819"
17+
18+
# 创建模板
19+
param = {
20+
"UniqName": uniqname,
21+
"Preset": presetname,
22+
"Description": description,
23+
"App": appname,
24+
"Output": [
25+
{
26+
"format":
27+
{
28+
"output_format": 257,
29+
"abr": 70000,
30+
"vbr": 700000,
31+
"fr": 23
32+
}
33+
}
34+
]
35+
}
36+
res = client.Preset(param)
37+
print json.dumps(res)
38+
39+
# 更新模板
40+
res = client.UpdatePreset(param)
41+
print json.dumps(res)
42+
43+
# 获取模板详情
44+
res = client.GetPresetDetail(App=appname, UniqName=uniqname, Preset=presetname)
45+
print json.dumps(res)
46+
47+
# 获取用户模板列表
48+
res = client.GetPresetList(App=appname, UniqName=uniqname)
49+
print json.dumps(res)
50+
51+
# 删除模板
52+
res = client.DelPreset(App=appname, UniqName=uniqname, Preset=presetname)
53+
print json.dumps(res)
54+
55+
# 启动外网拉流
56+
param1 = {
57+
"UniqName": uniqname,
58+
"StreamID": streamid,
59+
"SrcUrl": srcurl,
60+
"App": appname,
61+
"Params": "a",
62+
}
63+
res = client.StartStreamPull(param1)
64+
print json.dumps(res)
65+
66+
# 停止外网拉流
67+
param2 = {
68+
"UniqName": uniqname,
69+
"StreamID": streamid,
70+
"App": appname,
71+
}
72+
res = client.StopStreamPull(param2)
73+
print json.dumps(res)
74+
75+
# 获取转码任务列表
76+
res = client.GetStreamTranList(App=appname, UniqName=uniqname, StreamID=streamid, OutPull=outpull)
77+
print json.dumps(res)
78+
79+
# 获取用户已占用配额
80+
res = client.GetQuotaUsed(UniqName=uniqname)
81+
print json.dumps(res)

kscore/data/endpoints.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ partitions:
2626
cn-beijing-5:
2727
description: China Beijing (ZaoJunMiao)
2828

29+
cn-hongkong-2:
30+
description: China HongKong 2
31+
32+
cn-hongkong-1:
33+
description: China HongKong 1
34+
2935
cn-beijing-1:
3036
description: China Beijing (YiZhuang)
3137

@@ -67,7 +73,24 @@ partitions:
6773
endpoints:
6874
cn-beijing-6:
6975
hostname: iam.api.ksyun.com
70-
76+
ket:
77+
defaults:
78+
protocols:
79+
- http
80+
credentialScope:
81+
# eg: [ket].cn-beijing-6.api.ksyun.com
82+
service: ket
83+
# eg: ket.[cn-beijing-6].api.ksyun.com
84+
# partitionEndpoint: cn-beijing-6
85+
endpoints:
86+
cn-beijing-6:
87+
protocols:
88+
- http
89+
- https
90+
cn-shanghai-2:
91+
protocols:
92+
- http
93+
- https
7194
kec:
7295
defaults:
7396
credentialScope:
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
version: '2.0'
3+
metadata:
4+
apiVersion: '2017-01-01'
5+
endpointPrefix: ket
6+
jsonVersion: '1.1'
7+
serviceFullName: KSC OFFLINE Service
8+
signatureVersion: v4
9+
targetPrefix: ket
10+
protocol: json2
11+
12+
operations:
13+
Preset:
14+
name: Preset
15+
http:
16+
method: POST
17+
18+
UpdatePreset:
19+
name: UpdatePreset
20+
http:
21+
method: POST
22+
23+
DelPreset:
24+
name: DelPreset
25+
http:
26+
method: GET
27+
requestUri: /
28+
input:
29+
shape: PresetInstance
30+
31+
GetPresetList:
32+
name: GetPresetList
33+
http:
34+
method: GET
35+
requestUri: /
36+
input:
37+
shape: UserInstance
38+
39+
GetPresetDetail:
40+
name: GetPresetDetail
41+
http:
42+
method: GET
43+
requestUri: /
44+
input:
45+
shape: PresetInstance
46+
47+
StartStreamPull:
48+
name: StartStreamPull
49+
http:
50+
method: POST
51+
52+
StopStreamPull:
53+
name: StopStreamPull
54+
http:
55+
method: POST
56+
57+
GetStreamTranList:
58+
name: GetStreamTranList
59+
http:
60+
method: GET
61+
requestUri: /
62+
input:
63+
shape: StreamTranInstance
64+
65+
GetQuotaUsed:
66+
name: GetQuotaUsed
67+
http:
68+
method: GET
69+
requestUri: /
70+
input:
71+
shape: UniqNameInstance
72+
73+
shapes:
74+
App:
75+
type: string
76+
UniqName:
77+
type: string
78+
Preset:
79+
type: string
80+
StreamID:
81+
type: string
82+
OutPull:
83+
type: integer
84+
85+
UniqNameInstance:
86+
type: structure
87+
members:
88+
UniqName:
89+
shape: UniqName
90+
PresetInstance:
91+
type: structure
92+
members:
93+
App:
94+
shape: App
95+
UniqName:
96+
shape: UniqName
97+
Preset:
98+
shape: Preset
99+
UserInstance:
100+
type: structure
101+
members:
102+
App:
103+
shape: App
104+
UniqName:
105+
shape: UniqName
106+
StreamTranInstance:
107+
type: structure
108+
members:
109+
App:
110+
shape: App
111+
UniqName:
112+
shape: UniqName
113+
StreamID:
114+
shape: StreamID
115+
OutPull:
116+
shape: OutPull

kscore/data/vpc/2016-03-04/service-2.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,30 @@ operations:
129129
name: DescribeSubnetAvailableAddresses
130130
http:
131131
method: GET
132+
CreateNat:
133+
name: CreateNat
134+
http:
135+
method: GET
136+
DeleteNat:
137+
name: DeleteNat
138+
http:
139+
method: GET
132140
ModifyNat:
133141
name: ModifyNat
134142
http:
135143
method: GET
144+
DescribeNats:
145+
name: DescribeNats
146+
http:
147+
method: GET
148+
AssociateNat:
149+
name: AssociateNat
150+
http:
151+
method: GET
152+
DisassociateNat:
153+
name: DisassociateNat
154+
http:
155+
method: GET
136156

137157
shapes:
138158
Id:

kscore/ket.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
13+
def Preset(self,param):
14+
return self.client.preset(**param)
15+
16+
def UpdatePreset(self,param):
17+
return self.client.update_preset(**param)
18+
19+
def GetPresetList(self,App='live',UniqName=''):
20+
return self.client.get_preset_list(App=App,UniqName=UniqName)
21+
22+
def GetPresetDetail(self,App='live',UniqName='',Preset=''):
23+
return self.client.get_preset_detail(App=App,UniqName=UniqName,Preset=Preset)
24+
25+
def DelPreset(self,App='live',UniqName='',Preset=''):
26+
return self.client.del_preset(App=App,UniqName=UniqName,Preset=Preset)
27+
28+
def StartStreamPull(self,param):
29+
return self.client.start_stream_pull(**param)
30+
31+
def StopStreamPull(self,param):
32+
return self.client.stop_stream_pull(**param)
33+
34+
def GetStreamTranList(self,App='live',UniqName='',StreamID='',OutPull=-1):
35+
return self.client.get_stream_tran_list(App=App,UniqName=UniqName,StreamID=StreamID,OutPull=OutPull)
36+
37+
def GetQuotaUsed(self,UniqName=''):
38+
return self.client.get_quota_used(UniqName=UniqName)
39+
40+
def getKetClient(service_name,region_name,use_ssl=False,ks_access_key_id=None, ks_secret_access_key=None):
41+
return KetClient(service_name,region_name,use_ssl,ks_access_key_id, ks_secret_access_key)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
name='ksc-sdk-python',
3737
version=kscore.__version__,
3838
description='Low-level, data-driven core of ksc.',
39-
long_description=open('README.rst').read(),
39+
long_description='A low-level interface to a growing number of KSC Web Services.',
40+
#long_description=open('README.rst', encoding='utf-8').read(),
4041
author=AUTHOR,
4142
url='https://github.com/liuyichen/kscore',
4243
author_email=AUTHOR_EMAIL,

0 commit comments

Comments
 (0)