Skip to content

Commit c0264fd

Browse files
zhourongzhourong
authored andcommitted
Merge branch 'master' into trunk
2 parents 6e3832a + f7125fd commit c0264fd

File tree

8 files changed

+164
-65
lines changed

8 files changed

+164
-65
lines changed

README.rst

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Install 安装
99
----------------
1010

1111
+ pip 安装
12-
+ pip install kscore
12+
+ pip install ksc-sdk-python
1313

1414
+ github 安装
1515
+ 通过 `GitHub <https://github.com/liuyichen/kscore>`__ 下载
@@ -62,27 +62,33 @@ Service 服务
6262
| cn-shanghai-2 | 上海2区 |
6363
+-------------------+------------+
6464

65-
+ 服务列表 service_name, `详情参考API手册 <http://docs.ksyun.com>`__
6665

67-
+-------------------+------------+
68-
| service_name | 服务名 |
69-
+===================+============+
70-
| iam | |
71-
+-------------------+------------+
72-
| eip | |
73-
+-------------------+------------+
74-
| kec | |
75-
+-------------------+------------+
76-
| slb | |
77-
+-------------------+------------+
78-
| vpc | |
79-
+-------------------+------------+
80-
| monitor | |
81-
+-------------------+------------+
82-
| offline | |
83-
+-------------------+------------+
84-
| cdn | |
85-
+-------------------+------------+
66+
+ 已支持服务列表 service_name,具体方法与API的Action对应,如kec服务RunInstances对应为run_instances方法。 `详情参考API手册 <http://docs.ksyun.com>`__
67+
68+
+-------------------+----------------+
69+
| service | 服务名 |
70+
+===================+================+
71+
| iam | 身份与访问控制 |
72+
+-------------------+----------------+
73+
| eip | 弹性IP |
74+
+-------------------+----------------+
75+
| kec | 云服务器 |
76+
+-------------------+----------------+
77+
| tag | 标签服务 |
78+
+-------------------+----------------+
79+
| slb | 负载均衡 |
80+
+-------------------+----------------+
81+
| kcs | REDIS |
82+
+-------------------+----------------+
83+
| vpc | 虚拟私有网络 |
84+
+-------------------+----------------+
85+
| cdn | 内容分发网络 |
86+
+-------------------+----------------+
87+
| monitor | 云监控 |
88+
+-------------------+----------------+
89+
| offline | 视频转码 |
90+
+-------------------+----------------+
91+
8692

8793
----------------
8894
Method 方法

examples/tag.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
5+
if __name__ == "__main__":
6+
7+
s = get_session()
8+
9+
client = s.create_client("tag", region_name="cn-beijing-6", use_ssl=True)
10+
11+
print client.describe_tags()

kscore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import re
1717
import logging
1818

19-
__version__ = '1.0.7'
19+
__version__ = '1.0.8'
2020

2121

2222
class NullHandler(logging.Handler):

kscore/data/endpoints.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ partitions:
7272
defaults:
7373
credentialScope:
7474
service: kec
75-
EndpointRegion: cn-beijing-6
7675
endpoints:
7776
cn-beijing-6:
7877
protocols:
@@ -134,6 +133,20 @@ partitions:
134133
protocols:
135134
- http
136135

136+
tag:
137+
defaults:
138+
credentialScope:
139+
service: tag
140+
endpoints:
141+
cn-beijing-6:
142+
protocols:
143+
- http
144+
- https
145+
cn-shanghai-2:
146+
protocols:
147+
- http
148+
- https
149+
137150
cdn:
138151
defaults:
139152
protocols:
@@ -144,4 +157,5 @@ partitions:
144157
partitionEndpoint: cn-shanghai-1
145158
endpoints:
146159
cn-shanghai-1:
147-
hostname: cdn.api.ksyun.com
160+
hostname: cdn.api.ksyun.com
161+

kscore/data/iam/2015-11-01/service-2.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ metadata:
55
# Version 接口版本
66
apiVersion: '2015-11-01'
77
endpointPrefix: iam
8-
globalEndpoint: iam.api.ksyun.com
98
jsonVersion: '1.1'
109
serviceFullName: Identity and Access Management
1110
signatureVersion: v4
1211
targetPrefix: iam
1312
# query/ec2/json/query-json/rest-json/rest-xml
14-
protocol: json
13+
protocol: query-json
1514

1615
documentation: ''
1716

@@ -45,14 +44,8 @@ operations:
4544
shape: IamUser
4645

4746
ListUsers:
48-
name: ListUsers
4947
http:
5048
method: GET
51-
requestUri: /
52-
input:
53-
shape: Empty
54-
output:
55-
shape: ListUserResponse
5649

5750
GetUser:
5851
name: GetUser

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

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,79 @@ metadata:
1010
protocol: query-json
1111

1212
operations:
13-
RegionList:
14-
name: RegionList
13+
14+
RunInstances:
1515
http:
1616
method: GET
17-
input:
18-
shape: Empty
1917

20-
DescribeInstances:
21-
name: DescribeInstances
18+
TerminateInstances:
19+
http:
20+
method: GET
21+
22+
StartInstances:
23+
http:
24+
method: GET
25+
26+
StopInstances:
27+
http:
28+
method: GET
29+
30+
RebootInstances:
2231
http:
2332
method: GET
24-
shapes:
25-
Id:
26-
type: string #list/map/structure
2733

28-
Bool:
29-
type: bool
34+
MonitorInstances:
35+
http:
36+
method: GET
3037

31-
Int:
32-
type: int
38+
UnmonitorInstances:
39+
http:
40+
method: GET
3341

34-
DataTime:
35-
type: timestamp
42+
ModifyInstanceType:
43+
http:
44+
method: GET
3645

37-
Empty:
38-
type: structure
39-
members: {}
40-
documentation: ""
46+
ModifyInstanceImage:
47+
http:
48+
method: GET
4149

42-
NonEmptyString:
43-
type: string
44-
min: 1
50+
ModifyInstanceAttribute:
51+
http:
52+
method: GET
4553

46-
Message:
47-
type: string
54+
DescribeInstanceVnc:
55+
http:
56+
method: GET
4857

49-
InstanceId:
50-
type: structure
51-
required:
52-
- id
53-
members:
54-
id:
55-
shape: Id
56-
documentation: ""
58+
AttachNetworkInterface:
59+
http:
60+
method: GET
61+
62+
DescribeInstances:
63+
http:
64+
method: GET
65+
66+
ModifyNetworkInterfaceAttribute:
67+
http:
68+
method: GET
69+
70+
DetachNetworkInterface:
71+
http:
72+
method: GET
73+
74+
CreateImage:
75+
http:
76+
method: GET
77+
78+
DescribeImages:
79+
http:
80+
method: GET
81+
82+
RemoveImages:
83+
http:
84+
method: GET
85+
86+
ModifyImageAttribute:
87+
http:
88+
method: GET
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
version: '2.0'
3+
metadata:
4+
apiVersion: '2016-03-04'
5+
endpointPrefix: tag
6+
jsonVersion: '1.1'
7+
serviceFullName: Tag Service
8+
signatureVersion: v4
9+
targetPrefix: tag
10+
protocol: query-json
11+
12+
operations:
13+
CreateTags:
14+
http:
15+
method: GET
16+
DeleteTags:
17+
http:
18+
method: GET
19+
DescribeTags:
20+
http:
21+
method: GET
22+
DescribeTagValues:
23+
http:
24+
method: GET
25+
DescribeTagKeys:
26+
http:
27+
method: GET

kscore/serialize.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,15 @@ def serialize_to_request(self, parameters, operation_model):
194194
'X-Version': operation_model.metadata['apiVersion'],
195195
}
196196
)
197+
198+
if 'requestUri' in operation_model.http:
199+
serialized['url_path'] = operation_model.http['requestUri']
200+
197201
body_params = self.MAP_TYPE()
198202

203+
body_params['Action'] = operation_model.name
204+
body_params['Version'] = operation_model.metadata['apiVersion']
205+
199206
if shape is not None:
200207
self._serialize(body_params, parameters, shape)
201208
else:
@@ -363,6 +370,9 @@ def serialize_to_request(self, parameters, operation_model):
363370
'X-Version': operation_model.metadata['apiVersion'],
364371
}
365372
)
373+
if 'requestUri' in operation_model.http:
374+
serialized['url_path'] = operation_model.http['requestUri']
375+
366376
body_params = self.MAP_TYPE()
367377
custom_body = None
368378
if 'Body' in parameters:
@@ -377,7 +387,6 @@ def _serialize_data(self, serialized, data, body=None):
377387
if body is not None:
378388
serialized['body'] = json.dumps(body).encode(self.DEFAULT_ENCODING)
379389
serialized['query_string'] = data
380-
print serialized
381390
return serialized
382391

383392

@@ -395,6 +404,9 @@ def serialize_to_request(self, parameters, operation_model):
395404
serialized['method'] = operation_model.http.get('method',
396405
self.DEFAULT_METHOD)
397406

407+
if 'requestUri' in operation_model.http:
408+
serialized['url_path'] = operation_model.http['requestUri']
409+
398410
serialized['query_string'] = self.MAP_TYPE()
399411

400412
serialized['headers'] = {
@@ -497,6 +509,10 @@ class BaseRestSerializer(Serializer):
497509

498510
def serialize_to_request(self, parameters, operation_model):
499511
serialized = self._create_default_request()
512+
serialized['headers'] = {
513+
'X-Action': operation_model.name,
514+
'X-Version': operation_model.metadata['apiVersion']
515+
}
500516
serialized['method'] = operation_model.http.get('method',
501517
self.DEFAULT_METHOD)
502518
shape = operation_model.input_shape

0 commit comments

Comments
 (0)