Skip to content

Commit 791f367

Browse files
committed
initial upload
0 parents  commit 791f367

File tree

169 files changed

+41906
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+41906
-0
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
branch = True
3+
omit =
4+
kscore/vendored/*
5+
6+
[report]
7+
exclude_lines =
8+
raise NotImplementedError.*
9+
include =
10+
kscore/*

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: python
2+
python:
3+
- "2.6"
4+
- "2.7"
5+
- "3.3"
6+
- "3.4"
7+
- "3.5"
8+
sudo: false
9+
before_install:
10+
- if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
11+
echo "No pull requests can be sent to the master branch" 1>&2;
12+
exit 1;
13+
fi
14+
- pip install codecov
15+
install:
16+
- python scripts/ci/install
17+
script: python scripts/ci/run-tests
18+
after_success:
19+
- rm tests/coverage.xml && mv tests/.coverage ./ && codecov

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=========
2+
CHANGELOG
3+
=========
4+
5+
1.0.1a0
6+
======
7+
8+
* feature:``iam``: Update iam client to latest version
9+
10+
1.0.1a1
11+
======
12+
13+
* feature:fix tests
14+
15+
1.0.2
16+
======
17+
18+
* feature:``examples``: Add examples with ``kec``

LICENSE.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"). You
4+
may not use this file except in compliance with the License. A copy of
5+
the License is located at
6+
7+
http://aws.amazon.com/apache2.0/
8+
9+
or in the "license" file accompanying this file. This file is
10+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
ANY KIND, either express or implied. See the License for the specific
12+
language governing permissions and limitations under the License.

MANIFEST.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include README.rst
2+
include LICENSE.txt
3+
include requirements.txt
4+
include kscore/vendored/requests/cacert.pem
5+
recursive-include kscore/data *.json *.yaml
6+
graft docs
7+
prune docs/build
8+
graft tests

NOTICE

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Botocore includes a vendorized copy of the requests python library to ease installation.
2+
3+
Requests License
4+
================
5+
6+
Copyright 2013 Kenneth Reitz
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
21+
The requests library also includes some vendorized python libraries to ease installation.
22+
23+
Urllib3 License
24+
===============
25+
26+
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
27+
28+
Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt),
29+
Modifications copyright 2012 Kenneth Reitz.
30+
31+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
32+
software and associated documentation files (the "Software"), to deal in the Software
33+
without restriction, including without limitation the rights to use, copy, modify, merge,
34+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
35+
to whom the Software is furnished to do so, subject to the following conditions:
36+
37+
The above copyright notice and this permission notice shall be included in all copies or
38+
substantial portions of the Software.
39+
40+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
41+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
42+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
43+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
44+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
45+
DEALINGS IN THE SOFTWARE.
46+
47+
Chardet License
48+
===============
49+
50+
This library is free software; you can redistribute it and/or
51+
modify it under the terms of the GNU Lesser General Public
52+
License as published by the Free Software Foundation; either
53+
version 2.1 of the License, or (at your option) any later version.
54+
55+
This library is distributed in the hope that it will be useful,
56+
but WITHOUT ANY WARRANTY; without even the implied warranty of
57+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58+
Lesser General Public License for more details.
59+
60+
You should have received a copy of the GNU Lesser General Public
61+
License along with this library; if not, write to the Free Software
62+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
63+
02110-1301 USA
64+
65+
66+
67+
Bundle of CA Root Certificates
68+
==============================
69+
70+
This library is free software; you can redistribute it and/or
71+
modify it under the terms of the GNU Lesser General Public
72+
License as published by the Free Software Foundation; either
73+
version 2.1 of the License, or (at your option) any later version.
74+
75+
This library is distributed in the hope that it will be useful,
76+
but WITHOUT ANY WARRANTY; without even the implied warranty of
77+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78+
Lesser General Public License for more details.
79+
80+
You should have received a copy of the GNU Lesser General Public
81+
License along with this library; if not, write to the Free Software
82+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
83+
02110-1301

README.rst

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
kscore
2+
========
3+
4+
A low-level interface to a growing number of KSC Web Services. Reference from botocore.
5+
6+
`Documentation <http://www.ksyun.com/doc/search?word=API>`__
7+
8+
----------------
9+
安装
10+
----------------
11+
12+
+ pip 安装
13+
+ pip install kscore
14+
+ github 安装
15+
+ https://github.com/liuyichen/kscore 下载
16+
+ python setup.py install
17+
18+
----------------
19+
Credentials 配置
20+
----------------
21+
22+
+ 参考examples内示例
23+
24+
+ 配置文件: ``.kscore.cfg``
25+
26+
+ 所在位置: '/etc/kscore.cfg' 或 './.kscore.cfg' 或 'C:\\kscore.cfg'
27+
28+
+ 注意: 使用相对路径时,需与运行目录保持一致。
29+
::
30+
31+
[Credentials]
32+
ks_access_key_id=AKLTyW1V6ZWET7aIvdCeIH1cwQ
33+
ks_secret_access_key=OEoTK4IgEBIq3rlFsbpcNDs87w513D6aOwdXxP6QHuvWlonSRYeKQyTzqc1XkUvpuQ==
34+
35+
36+
+ 或运行时配置
37+
+ session.set_credentials(access_key_id, secret_access_key, session_token=None)
38+
39+
----------------
40+
Service 使用
41+
----------------
42+
43+
+ create_client 方法
44+
| service_name 服务,必须参数,例 iam
45+
| region_name=None 大区,必须参数,全局服务可以为None
46+
| api_version=None API版本,默认使用最近版本
47+
| use_ssl=True 是否使用HTTPS,如接口支持情况下,优先使用
48+
| verify=None 是否验证SSL证书
49+
| endpoint_url=None
50+
| ks_access_key_id=None
51+
| ks_secret_access_key=None
52+
| ks_session_token=None
53+
54+
55+
+ 已支持大区 region_name 参考data/endpoints.yaml
56+
| cn-beijing-5 北京5区
57+
| cn-beijing-6 北京6区
58+
| cn-shanghai-2 上海2区
59+
60+
+ IAM
61+
62+
::
63+
64+
from kscore.session import get_session
65+
66+
if __name__ == "__main__":
67+
s = get_session()
68+
69+
client = s.create_client("iam", use_ssl=False)
70+
71+
users = client.list_users()
72+
73+
+ KEC
74+
75+
::
76+
77+
from kscore.session import get_session
78+
79+
if __name__ == "__main__":
80+
s = get_session()
81+
82+
client = s.create_client("kec", "cn-beijing-6", use_ssl=False)
83+
84+
client.[your method]()
85+
86+
+ MONITOR
87+
88+
::
89+
90+
from kscore.session import get_session
91+
92+
if __name__ == "__main__":
93+
s = get_session()
94+
95+
client = s.create_client("monitor", "cn-beijing-5", use_ssl=True)
96+
97+
m=client.get_metric_statistics(InstanceID="6f582c78-5d49-438e-bf2d-db4345daf503",Namespace="eip",MetricName="qos.bps_in",StartTime="2016-08-16T17:09:00Z",EndTime="2016-08-16T23:56:00Z",Period="600",Aggregate="Average")
98+
99+
print json.dumps(m,sort_keys=True,indent=4)
100+
101+
+ 更多
102+
103+
::
104+
105+
欢迎补充
106+
107+
------------------
108+
Data 更多服务配置
109+
------------------
110+
+ 参考 https://github.com/liuyichen/kscore/issues
111+
+ ENDPOINT 配置
112+
+ data\\endpoints.yaml
113+
114+
::
115+
116+
version: n
117+
partitions:
118+
- partition:
119+
...
120+
# REGION 列表
121+
regions:
122+
...
123+
# 服务列表
124+
- service:
125+
...
126+
127+
+ SERVICE 配置
128+
+ data\\[service]\\[version]\\service-2.yaml
129+
130+
::
131+
132+
version: n
133+
# API 配置
134+
metadata:
135+
...
136+
# 操作方法
137+
operations:
138+
...
139+
# 请求及返回的结构体
140+
shapes:
141+
...
142+
143+
+ 请参考IAM,KEC等配置
144+
145+
配置文件变更后请重新安装 python setup.py install
146+
147+
148+
--------------------
149+
TESTS 测试
150+
--------------------
151+
152+
+ 基本接口测试
153+
154+
\tests\acceptance> behave
155+
156+
+ 各服务测试用例
157+
158+
\tests>nosetests --with-xunit --cover-erase --with-coverage --cover-package kscore --cover-xml -v integration
159+
160+
--------------------
161+
Contact Information
162+
--------------------
163+
164+
群 号: 367780788
165+
邮 箱: liuyc.mail@gmail.com

examples/.kscore.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Credentials]
2+
ks_access_key_id =
3+
ks_secret_access_key =

examples/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- encoding: utf-8 -*-
2+
from __future__ import unicode_literals

examples/iam.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
5+
if __name__ == "__main__":
6+
s = get_session()
7+
8+
client = s.create_client("iam", use_ssl=False)
9+
10+
users = client.list_users()
11+
12+
client.create_user(UserName="test22", RealName=u"刘一辰")
13+
14+
client.update_user(UserName="test22",)
15+
16+
client.delete_user(UserName="test22")

examples/kec.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
5+
if __name__ == "__main__":
6+
s = get_session()
7+
8+
client = s.create_client("kec", "cn-beijing-6", use_ssl=True)
9+
10+
print client.describe_instances()
11+
12+
# client.create_user(UserName="test22", RealName=u"刘一辰")
13+
14+
# client.update_user(UserName="test22",)
15+
16+
# client.delete_user(UserName="test22")

examples/kog.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
5+
if __name__ == "__main__":
6+
s = get_session()
7+
8+
client = s.create_client("kog", use_ssl=True)
9+
10+
projects = client.get_project_list()
11+
12+
project = client.add_project(name='123123', comment='123123')
13+
14+
project.update(name="bcd")
15+
16+
client.edit_project(**project)
17+
18+
client.delete_project(id=project['id'])
19+
20+
assert projects == client.get_project_list()

0 commit comments

Comments
 (0)