Skip to content

Trunk #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions examples/kcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- encoding:utf-8 -*-

from kscore.session import get_session

if __name__ == "__main__":
s = get_session()

#确定服务名称以及机房
kcsClient = s.create_client("kcs", "cn-shanghai-3", use_ssl=False)

# 创建缓存服务
#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'}))

# 查询缓存服务列表
#print(kcsClient.describe_cache_clusters(**{'Action': 'DescribeCacheClusters', 'Version': '2016-07-01', 'Offset': 0, 'Limit': 5, 'OrderBy': 'created,desc'}))

# 查询缓存服务详情
#print(kcsClient.describe_cache_cluster(**{'Action': 'DescribeCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 重命名缓存服务
#print(kcsClient.rename_cache_cluster(**{'Action': 'RenameCacheCluster', 'Version': '2016-07-01', 'Name': 'pjl_test_sdk', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 清空缓存服务
#print(kcsClient.flush_cache_cluster(**{'Action': 'FlushCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 锁定缓存服务
#print(kcsClient.lock_cache_cluster(**{'Action': 'LockCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 解锁缓存服务
#print(kcsClient.unlock_cache_cluster(**{'Action': 'UnlockCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 更配缓存服务
#print(kcsClient.resize_cache_cluster(**{'Action': 'ResizeCacheCluster', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'Capacity': 2}))

# 删除缓存服务
#print(kcsClient.delete_cache_cluster(**{'Action': 'DeleteCacheCluster', 'Version': '2016-07-01', 'CacheId': 'b80ef266-dd52-47b2-9377-6a4a73626c19'}))

# 查询缓存服务参数
#print(kcsClient.describe_cache_parameters(**{'Action': 'DescribeCacheParameters', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 设置缓存服务参数
#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'}))

# 查询缓存服务安全规则
#print(kcsClient.describe_cache_security_rules(**{'Action': 'DescribeCacheSecurityRules', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb'}))

# 设置缓存服务安全规则
#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'}))

# 删除缓存服务安全规则
#print(kcsClient.delete_cache_security_rule(**{'Action': 'DeleteCacheSecurityRule', 'Version': '2016-07-01', 'CacheId': '01988fc0-6041-49d2-b6b5-e2385e5d5edb', 'SecurityRuleId': 105}))
36 changes: 35 additions & 1 deletion kscore/data/endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ partitions:

cn-beijing-5:
description: China Beijing (ZaoJunMiao)

cn-beijing-1:
description: China Beijing (YiZhuang)

cn-beijing-3:
description: China Beijing

cn-shanghai-1:
description: China ShangHai

cn-shanghai-3:
description: China ShangHai (PengBoShiVPC)
# services
services:

Expand Down Expand Up @@ -98,4 +110,26 @@ partitions:
protocols:
- http


kcs:
defaults:
credentialScope:
service: kcs
endpoints:
cn-shanghai-3:
protocols:
- http
cn-beijing-1:
protocols:
- http
cn-beijing-3:
protocols:
- http
cn-beijing-6:
protocols:
- http
cn-shanghai-1:
protocols:
- http
cn-shanghai-2:
protocols:
- http
252 changes: 252 additions & 0 deletions kscore/data/kcs/2016-07-01/service-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
---
version: '2.0'

metadata:
apiVersion: '2016-07-01'
endpointPrefix: kcs
jsonVersion: '1.1'
serviceFullName: KCS Service
signatureVersion: v4
targetPrefix: kcs
protocol: kcs

operations:
CreateCacheCluster:
name: CreateCacheCluster
http:
method: POST
input:
shape: CreateCacheRequest

DescribeCacheClusters:
name: DescribeCacheClusters
http:
method: GET
input:
shape: DescribeCachesRequest

DescribeCacheCluster:
name: DescribeCacheCluster
http:
method: GET
input:
shape: CommonCacheRequest

FlushCacheCluster:
name: FlushCacheCluster
http:
method: PUT
input:
shape: CommonCacheRequest

LockCacheCluster:
name: LockCacheCluster
http:
method: PUT
input:
shape: CommonCacheRequest

UnlockCacheCluster:
name: UnlockCacheCluster
http:
method: PUT
input:
shape: CommonCacheRequest

RenameCacheCluster:
name: RenameCacheCluster
http:
method: PUT
input:
shape: RenameCacheRequest

ResizeCacheCluster:
name: ResizeCacheCluster
http:
method: PUT
input:
shape: ResizeCacheRequest

DeleteCacheCluster:
name: DeleteCacheCluster
http:
method: DELETE
input:
shape: CommonCacheRequest

SetCacheParameters:
name: SetCacheParameters
http:
method: PUT

DescribeCacheParameters:
name: DescribeCacheParameters
http:
method: GET
input:
shape: CommonCacheRequest

SetCacheSecurityRules:
name: SetCacheSecurityRules
http:
method: PUT

DeleteCacheSecurityRule:
name: DeleteCacheSecurityRule
http:
method: DELETE
input:
shape: DelSecurityRuleRequest

DescribeCacheSecurityRules:
name: DescribeCacheSecurityRules
http:
method: GET
input:
shape: CommonCacheRequest

shapes:
Id:
type: string

Bool:
type: bool

Int:
type: integer

String:
type: string

DataTime:
type: timestamp

Empty:
type: structure
members: {}

NonEmptyString:
type: string
min: 1

Message:
type: string

CommonCacheRequest:
type: structure
required:
- Action
- Version
- CacheId
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
CacheId:
shape: NonEmptyString

CreateCacheRequest:
type: structure
required:
- Action
- Version
- Name
- Capacity
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
Name:
shape: NonEmptyString
Capacity:
shape: Int
Engine:
shape: NonEmptyString
Mode:
shape: Int
NetType:
shape: Int
VpcId:
shape: NonEmptyString
VnetId:
shape: NonEmptyString

DescribeCachesRequest:
type: structure
required:
- Action
- Version
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
CacheId:
shape: NonEmptyString
Name:
shape: NonEmptyString
Vip:
shape: NonEmptyString
VpcId:
shape: NonEmptyString
VnetId:
shape: NonEmptyString
Offset:
shape: Int
Limit:
shape: Int
OrderBy:
shape: NonEmptyString

RenameCacheRequest:
type: structure
required:
- Action
- Version
- Name
- CacheId
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
Name:
shape: NonEmptyString
CacheId:
shape: NonEmptyString

ResizeCacheRequest:
type: structure
required:
- Action
- Version
- CacheId
- Capacity
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
CacheId:
shape: NonEmptyString
Capacity:
shape: Int

DelSecurityRuleRequest:
type: structure
required:
- Action
- Version
- CacheId
- SecurityRuleId
members:
Action:
shape: NonEmptyString
Version:
shape: NonEmptyString
CacheId:
shape: NonEmptyString
SecurityRuleId:
shape: Int