Skip to content

Commit 1c27ff7

Browse files
author
金山云SDK
authored
Merge pull request KscSDK#16 from KscSDK/trunk
Trunk
2 parents 5295037 + 2cc6a24 commit 1c27ff7

File tree

3 files changed

+338
-1
lines changed

3 files changed

+338
-1
lines changed

examples/kcs.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
5+
if __name__ == "__main__":
6+
s = get_session()
7+
8+
#确定服务名称以及机房
9+
kcsClient = s.create_client("kcs", "cn-shanghai-3", use_ssl=False)
10+
11+
# 创建缓存服务
12+
#print(kcsClient.create_cache_cluster(**{'Action': 'CreateCacheCluster', 'Version': '2016-07-01', 'Name': 'pjl_sdk_test0921', 'Capacity': 1, 'NetType': 2, 'VpcId': '3c12ccdf-9b8f-4d9b-8aa6-a523897e97a1', 'VnetId': '293c16a5-c757-405c-a693-3b2a3adead50'}))
13+
14+
# 查询缓存服务列表
15+
#print(kcsClient.describe_cache_clusters(**{'Action': 'DescribeCacheClusters', 'Version': '2016-07-01', 'Offset': 0, 'Limit': 5, 'OrderBy': 'created,desc'}))
16+
17+
# 查询缓存服务详情
18+
#print(kcsClient.describe_cache_cluster(**{'Action': 'DescribeCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
19+
20+
# 重命名缓存服务
21+
#print(kcsClient.rename_cache_cluster(**{'Action': 'RenameCacheCluster', 'Version': '2016-07-01', 'Name': 'pjl_test_sdk', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
22+
23+
# 清空缓存服务
24+
#print(kcsClient.flush_cache_cluster(**{'Action': 'FlushCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
25+
26+
# 锁定缓存服务
27+
#print(kcsClient.lock_cache_cluster(**{'Action': 'LockCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
28+
29+
# 解锁缓存服务
30+
#print(kcsClient.unlock_cache_cluster(**{'Action': 'UnlockCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
31+
32+
# 更配缓存服务
33+
#print(kcsClient.resize_cache_cluster(**{'Action': 'ResizeCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'Capacity': 2}))
34+
35+
# 删除缓存服务
36+
#print(kcsClient.delete_cache_cluster(**{'Action': 'DeleteCacheCluster', 'Version': '2016-07-01', 'CacheId': 'b80ef266-dd52-47b2-9377-6a4a73626c19'}))
37+
38+
# 查询缓存服务参数
39+
#print(kcsClient.describe_cache_parameters(**{'Action': 'DescribeCacheParameters', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
40+
41+
# 设置缓存服务参数
42+
#print(kcsClient.set_cache_parameters(**{'Action': 'SetCacheParameters', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'Parameters.ParameterName.1': 'maxmemory-policy', 'Parameters.ParameterValue.1': 'allkeys-lru', 'ResetAllParameters': 'true'}))
43+
44+
# 查询缓存服务安全规则
45+
#print(kcsClient.describe_cache_security_rules(**{'Action': 'DescribeCacheSecurityRules', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))
46+
47+
# 设置缓存服务安全规则
48+
#print(kcsClient.set_cache_security_rules(**{'Action': 'SetCacheSecurityRules', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'SecurityRules.Cidr.1': '192.168.18.17/21'}))
49+
50+
# 删除缓存服务安全规则
51+
#print(kcsClient.delete_cache_security_rule(**{'Action': 'DeleteCacheSecurityRule', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'SecurityRuleId': 105}))

kscore/data/endpoints.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ partitions:
2525

2626
cn-beijing-5:
2727
description: China Beijing (ZaoJunMiao)
28+
29+
cn-beijing-1:
30+
description: China Beijing (YiZhuang)
31+
32+
cn-beijing-3:
33+
description: China Beijing
34+
35+
cn-shanghai-1:
36+
description: China ShangHai
37+
38+
cn-shanghai-3:
39+
description: China ShangHai (PengBoShiVPC)
2840
# services
2941
services:
3042

@@ -98,4 +110,26 @@ partitions:
98110
protocols:
99111
- http
100112

101-
113+
kcs:
114+
defaults:
115+
credentialScope:
116+
service: kcs
117+
endpoints:
118+
cn-shanghai-3:
119+
protocols:
120+
- http
121+
cn-beijing-1:
122+
protocols:
123+
- http
124+
cn-beijing-3:
125+
protocols:
126+
- http
127+
cn-beijing-6:
128+
protocols:
129+
- http
130+
cn-shanghai-1:
131+
protocols:
132+
- http
133+
cn-shanghai-2:
134+
protocols:
135+
- http
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
---
2+
version: '2.0'
3+
4+
metadata:
5+
apiVersion: '2016-07-01'
6+
endpointPrefix: kcs
7+
jsonVersion: '1.1'
8+
serviceFullName: KCS Service
9+
signatureVersion: v4
10+
targetPrefix: kcs
11+
protocol: kcs
12+
13+
operations:
14+
CreateCacheCluster:
15+
name: CreateCacheCluster
16+
http:
17+
method: POST
18+
input:
19+
shape: CreateCacheRequest
20+
21+
DescribeCacheClusters:
22+
name: DescribeCacheClusters
23+
http:
24+
method: GET
25+
input:
26+
shape: DescribeCachesRequest
27+
28+
DescribeCacheCluster:
29+
name: DescribeCacheCluster
30+
http:
31+
method: GET
32+
input:
33+
shape: CommonCacheRequest
34+
35+
FlushCacheCluster:
36+
name: FlushCacheCluster
37+
http:
38+
method: PUT
39+
input:
40+
shape: CommonCacheRequest
41+
42+
LockCacheCluster:
43+
name: LockCacheCluster
44+
http:
45+
method: PUT
46+
input:
47+
shape: CommonCacheRequest
48+
49+
UnlockCacheCluster:
50+
name: UnlockCacheCluster
51+
http:
52+
method: PUT
53+
input:
54+
shape: CommonCacheRequest
55+
56+
RenameCacheCluster:
57+
name: RenameCacheCluster
58+
http:
59+
method: PUT
60+
input:
61+
shape: RenameCacheRequest
62+
63+
ResizeCacheCluster:
64+
name: ResizeCacheCluster
65+
http:
66+
method: PUT
67+
input:
68+
shape: ResizeCacheRequest
69+
70+
DeleteCacheCluster:
71+
name: DeleteCacheCluster
72+
http:
73+
method: DELETE
74+
input:
75+
shape: CommonCacheRequest
76+
77+
SetCacheParameters:
78+
name: SetCacheParameters
79+
http:
80+
method: PUT
81+
82+
DescribeCacheParameters:
83+
name: DescribeCacheParameters
84+
http:
85+
method: GET
86+
input:
87+
shape: CommonCacheRequest
88+
89+
SetCacheSecurityRules:
90+
name: SetCacheSecurityRules
91+
http:
92+
method: PUT
93+
94+
DeleteCacheSecurityRule:
95+
name: DeleteCacheSecurityRule
96+
http:
97+
method: DELETE
98+
input:
99+
shape: DelSecurityRuleRequest
100+
101+
DescribeCacheSecurityRules:
102+
name: DescribeCacheSecurityRules
103+
http:
104+
method: GET
105+
input:
106+
shape: CommonCacheRequest
107+
108+
shapes:
109+
Id:
110+
type: string
111+
112+
Bool:
113+
type: bool
114+
115+
Int:
116+
type: integer
117+
118+
String:
119+
type: string
120+
121+
DataTime:
122+
type: timestamp
123+
124+
Empty:
125+
type: structure
126+
members: {}
127+
128+
NonEmptyString:
129+
type: string
130+
min: 1
131+
132+
Message:
133+
type: string
134+
135+
CommonCacheRequest:
136+
type: structure
137+
required:
138+
- Action
139+
- Version
140+
- CacheId
141+
members:
142+
Action:
143+
shape: NonEmptyString
144+
Version:
145+
shape: NonEmptyString
146+
CacheId:
147+
shape: NonEmptyString
148+
149+
CreateCacheRequest:
150+
type: structure
151+
required:
152+
- Action
153+
- Version
154+
- Name
155+
- Capacity
156+
members:
157+
Action:
158+
shape: NonEmptyString
159+
Version:
160+
shape: NonEmptyString
161+
Name:
162+
shape: NonEmptyString
163+
Capacity:
164+
shape: Int
165+
Engine:
166+
shape: NonEmptyString
167+
Mode:
168+
shape: Int
169+
NetType:
170+
shape: Int
171+
VpcId:
172+
shape: NonEmptyString
173+
VnetId:
174+
shape: NonEmptyString
175+
176+
DescribeCachesRequest:
177+
type: structure
178+
required:
179+
- Action
180+
- Version
181+
members:
182+
Action:
183+
shape: NonEmptyString
184+
Version:
185+
shape: NonEmptyString
186+
CacheId:
187+
shape: NonEmptyString
188+
Name:
189+
shape: NonEmptyString
190+
Vip:
191+
shape: NonEmptyString
192+
VpcId:
193+
shape: NonEmptyString
194+
VnetId:
195+
shape: NonEmptyString
196+
Offset:
197+
shape: Int
198+
Limit:
199+
shape: Int
200+
OrderBy:
201+
shape: NonEmptyString
202+
203+
RenameCacheRequest:
204+
type: structure
205+
required:
206+
- Action
207+
- Version
208+
- Name
209+
- CacheId
210+
members:
211+
Action:
212+
shape: NonEmptyString
213+
Version:
214+
shape: NonEmptyString
215+
Name:
216+
shape: NonEmptyString
217+
CacheId:
218+
shape: NonEmptyString
219+
220+
ResizeCacheRequest:
221+
type: structure
222+
required:
223+
- Action
224+
- Version
225+
- CacheId
226+
- Capacity
227+
members:
228+
Action:
229+
shape: NonEmptyString
230+
Version:
231+
shape: NonEmptyString
232+
CacheId:
233+
shape: NonEmptyString
234+
Capacity:
235+
shape: Int
236+
237+
DelSecurityRuleRequest:
238+
type: structure
239+
required:
240+
- Action
241+
- Version
242+
- CacheId
243+
- SecurityRuleId
244+
members:
245+
Action:
246+
shape: NonEmptyString
247+
Version:
248+
shape: NonEmptyString
249+
CacheId:
250+
shape: NonEmptyString
251+
SecurityRuleId:
252+
shape: Int

0 commit comments

Comments
 (0)