From 31ab85344d407dda5042b80df56df48f77b2f4db Mon Sep 17 00:00:00 2001 From: PANGJIANLIN Date: Mon, 26 Sep 2016 16:34:14 +0800 Subject: [PATCH 1/2] kcs sdk for test --- examples/kcs.py | 50 +++++ kscore/data/endpoints.yaml | 37 +++- kscore/data/kcs/2016-07-01/service-2.yaml | 252 ++++++++++++++++++++++ 3 files changed, 338 insertions(+), 1 deletion(-) create mode 100644 examples/kcs.py create mode 100644 kscore/data/kcs/2016-07-01/service-2.yaml diff --git a/examples/kcs.py b/examples/kcs.py new file mode 100644 index 0000000..e99de5a --- /dev/null +++ b/examples/kcs.py @@ -0,0 +1,50 @@ +# -*- 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})) \ No newline at end of file diff --git a/kscore/data/endpoints.yaml b/kscore/data/endpoints.yaml index 8a5417d..0a2e3f9 100644 --- a/kscore/data/endpoints.yaml +++ b/kscore/data/endpoints.yaml @@ -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: @@ -98,4 +110,27 @@ partitions: protocols: - http - + kcs: + defaults: + credentialScope: + service: kcs + EndpointRegion: cn-shanghai-3 + 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 diff --git a/kscore/data/kcs/2016-07-01/service-2.yaml b/kscore/data/kcs/2016-07-01/service-2.yaml new file mode 100644 index 0000000..426bf13 --- /dev/null +++ b/kscore/data/kcs/2016-07-01/service-2.yaml @@ -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 \ No newline at end of file From 49d903912a3ced37fe7398ef7ba34332cb46a7e0 Mon Sep 17 00:00:00 2001 From: PANGJIANLIN Date: Wed, 26 Oct 2016 11:26:45 +0800 Subject: [PATCH 2/2] fix problem in endpoints --- examples/kcs.py | 1 + kscore/data/endpoints.yaml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/kcs.py b/examples/kcs.py index e99de5a..2b442b6 100644 --- a/examples/kcs.py +++ b/examples/kcs.py @@ -5,6 +5,7 @@ if __name__ == "__main__": s = get_session() + #确定服务名称以及机房 kcsClient = s.create_client("kcs", "cn-shanghai-3", use_ssl=False) # 创建缓存服务 diff --git a/kscore/data/endpoints.yaml b/kscore/data/endpoints.yaml index 0a2e3f9..3f0d97f 100644 --- a/kscore/data/endpoints.yaml +++ b/kscore/data/endpoints.yaml @@ -114,7 +114,6 @@ partitions: defaults: credentialScope: service: kcs - EndpointRegion: cn-shanghai-3 endpoints: cn-shanghai-3: protocols: