baiducloud-python-sdk-core 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- baiducloud_python_sdk_core-0.0.1/ChangeLog.md +2 -0
- baiducloud_python_sdk_core-0.0.1/LICENSE +177 -0
- baiducloud_python_sdk_core-0.0.1/MANIFEST.in +2 -0
- baiducloud_python_sdk_core-0.0.1/PKG-INFO +85 -0
- baiducloud_python_sdk_core-0.0.1/README-CN.md +38 -0
- baiducloud_python_sdk_core-0.0.1/README.md +38 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/__init__.py +24 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/abstract_model.py +33 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/auth/__init__.py +0 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/auth/bce_credentials.py +27 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/auth/bce_v1_signer.py +92 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/bce_base_client.py +90 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/bce_client_configuration.py +87 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/bce_response.py +61 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/compat.py +125 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/exception.py +52 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/__init__.py +0 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/bce_http_client.py +280 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/handler.py +76 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/http_content_types.py +18 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/http_headers.py +122 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/http/http_methods.py +25 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/protocol.py +25 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/region.py +27 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/retry/__init__.py +0 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/retry/retry_policy.py +133 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core/utils.py +762 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core.egg-info/PKG-INFO +85 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core.egg-info/SOURCES.txt +33 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core.egg-info/dependency_links.txt +1 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core.egg-info/requires.txt +3 -0
- baiducloud_python_sdk_core-0.0.1/baiducloud_python_sdk_core.egg-info/top_level.txt +1 -0
- baiducloud_python_sdk_core-0.0.1/setup.cfg +7 -0
- baiducloud_python_sdk_core-0.0.1/setup.py +70 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: baiducloud-python-sdk-core
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Baidu Cloud Core SDK Library for Python
|
|
5
|
+
Home-page: https://github.com/baidubce/baiducloud-sdk-python
|
|
6
|
+
Author: Baidu Cloud SDK
|
|
7
|
+
Author-email:
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Project-URL: Source, https://github.com/baidubce/baiducloud-sdk-python
|
|
10
|
+
Project-URL: Documentation, https://github.com/baidubce/baiducloud-sdk-python/tree/master/docs
|
|
11
|
+
Project-URL: Changelog, https://github.com/baidubce/baiducloud-sdk-python/blob/master/baiducloud-python-sdk-core/ChangeLog.md
|
|
12
|
+
Keywords: baiducloud,core,sdk
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 2
|
|
18
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
29
|
+
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: pycryptodome>=3.8.0
|
|
33
|
+
Requires-Dist: future>=0.6.0
|
|
34
|
+
Requires-Dist: six>=1.4.0
|
|
35
|
+
Dynamic: author
|
|
36
|
+
Dynamic: classifier
|
|
37
|
+
Dynamic: description
|
|
38
|
+
Dynamic: description-content-type
|
|
39
|
+
Dynamic: home-page
|
|
40
|
+
Dynamic: keywords
|
|
41
|
+
Dynamic: license
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
Dynamic: project-url
|
|
44
|
+
Dynamic: requires-dist
|
|
45
|
+
Dynamic: requires-python
|
|
46
|
+
Dynamic: summary
|
|
47
|
+
|
|
48
|
+
English | [简体中文](README-CN.md)
|
|
49
|
+
|
|
50
|
+
## Baidu Cloud Core SDK for Python
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
- **Install with pip**
|
|
59
|
+
|
|
60
|
+
Python SDK uses a common package management tool named `pip`. If pip is not installed, see the [pip user guide](https://pip.pypa.io/en/stable/installing/ "pip User Guide") to install pip.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Install the baiducloud_python_sdk_core
|
|
64
|
+
pip install baiducloud_python_sdk_core
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Issues
|
|
68
|
+
|
|
69
|
+
[Opening an Issue](https://github.com/baidubce/baiducloud-python-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
[Quick Examples](https://github.com/baidubce/baidubce-python-sdk/blob/master/docs/0-Usage-CN.md#%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8)
|
|
74
|
+
|
|
75
|
+
## Changelog
|
|
76
|
+
|
|
77
|
+
Detailed changes for each release are documented in the [release notes](./ChangeLog.md).
|
|
78
|
+
|
|
79
|
+
## References
|
|
80
|
+
|
|
81
|
+
- [Latest Release](https://github.com/baidubce/baidubce-python-sdk)
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[English](README.md) | 简体中文
|
|
2
|
+
|
|
3
|
+
## Baidu Cloud Core SDK for Python
|
|
4
|
+
|
|
5
|
+
## 要求
|
|
6
|
+
|
|
7
|
+
- Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
- **使用 pip 安装(推荐)**
|
|
12
|
+
|
|
13
|
+
如未安装 `pip`, 请先至pip官网 [pip user guide](https://pip.pypa.io/en/stable/installing/ "pip User Guide") 安装pip .
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 安装 baiducloud_python_sdk_core
|
|
17
|
+
pip install baiducloud_python_sdk_core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 问题
|
|
21
|
+
|
|
22
|
+
[提交 Issue](https://github.com/baidubce/baiducloud-python-sdk/issues/new),不符合指南的问题可能会立即关闭。
|
|
23
|
+
|
|
24
|
+
## 使用说明
|
|
25
|
+
|
|
26
|
+
[快速使用](https://github.com/baidubce/baidubce-python-sdk/blob/master/docs/0-Usage-CN.md#%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8)
|
|
27
|
+
|
|
28
|
+
## 发行说明
|
|
29
|
+
|
|
30
|
+
每个版本的详细更改记录在[发行说明](./ChangeLog.md)中。
|
|
31
|
+
|
|
32
|
+
## 相关
|
|
33
|
+
|
|
34
|
+
- [最新源码](https://github.com/baidubce/baidubce-python-sdk)
|
|
35
|
+
|
|
36
|
+
## 许可证
|
|
37
|
+
|
|
38
|
+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
English | [简体中文](README-CN.md)
|
|
2
|
+
|
|
3
|
+
## Baidu Cloud Core SDK for Python
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
- **Install with pip**
|
|
12
|
+
|
|
13
|
+
Python SDK uses a common package management tool named `pip`. If pip is not installed, see the [pip user guide](https://pip.pypa.io/en/stable/installing/ "pip User Guide") to install pip.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install the baiducloud_python_sdk_core
|
|
17
|
+
pip install baiducloud_python_sdk_core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Issues
|
|
21
|
+
|
|
22
|
+
[Opening an Issue](https://github.com/baidubce/baiducloud-python-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
[Quick Examples](https://github.com/baidubce/baidubce-python-sdk/blob/master/docs/0-Usage-CN.md#%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8)
|
|
27
|
+
|
|
28
|
+
## Changelog
|
|
29
|
+
|
|
30
|
+
Detailed changes for each release are documented in the [release notes](./ChangeLog.md).
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
|
|
34
|
+
- [Latest Release](https://github.com/baidubce/baidubce-python-sdk)
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2014 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
This module defines some common string constants.
|
|
15
|
+
"""
|
|
16
|
+
from builtins import str
|
|
17
|
+
from builtins import bytes
|
|
18
|
+
from . import protocol
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
SDK_VERSION = b'0.0.1'
|
|
22
|
+
DEFAULT_SERVICE_DOMAIN = b'bcebos.com'
|
|
23
|
+
URL_PREFIX = b'/v1'
|
|
24
|
+
DEFAULT_ENCODING = 'UTF-8'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright 2014 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
This module provides a general model class for baiducloud services.
|
|
16
|
+
"""
|
|
17
|
+
class AbstractModel(object):
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
def __init__(self):
|
|
22
|
+
self._map = None
|
|
23
|
+
|
|
24
|
+
def to_dict(self):
|
|
25
|
+
return self._map
|
|
26
|
+
|
|
27
|
+
def from_dict(self, map=None):
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
def to_json_string(self, *args, **kwargs):
|
|
31
|
+
if "ensure_ascii" not in kwargs:
|
|
32
|
+
kwargs["ensure_ascii"] = False
|
|
33
|
+
return json.dumps(self.to_dict(), *args, **kwargs)
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright 2014 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
Provides access to the BCE credentials used for accessing BCE services: BCE access key ID and
|
|
15
|
+
secret access key.
|
|
16
|
+
These credentials are used to securely sign requests to BCE services.
|
|
17
|
+
"""
|
|
18
|
+
from baiducloud_python_sdk_core import compat
|
|
19
|
+
|
|
20
|
+
class BceCredentials(object):
|
|
21
|
+
"""
|
|
22
|
+
Provides access to the BCE credentials used for accessing BCE services:
|
|
23
|
+
BCE access key ID and secret access key.
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, access_key_id, secret_access_key):
|
|
26
|
+
self.access_key_id = compat.convert_to_bytes(access_key_id)
|
|
27
|
+
self.secret_access_key = compat.convert_to_bytes(secret_access_key)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Copyright 2014 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
This module provides authentication functions for bce services.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import absolute_import
|
|
17
|
+
from builtins import str
|
|
18
|
+
from builtins import bytes
|
|
19
|
+
import hashlib
|
|
20
|
+
import hmac
|
|
21
|
+
import logging
|
|
22
|
+
|
|
23
|
+
from baiducloud_python_sdk_core.http import http_headers
|
|
24
|
+
from baiducloud_python_sdk_core import utils
|
|
25
|
+
from baiducloud_python_sdk_core import compat
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_logger = logging.getLogger(__name__)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _get_canonical_headers(headers, headers_to_sign=None):
|
|
32
|
+
headers = headers or {}
|
|
33
|
+
|
|
34
|
+
if headers_to_sign is None or len(headers_to_sign) == 0:
|
|
35
|
+
headers_to_sign = set([b"host",
|
|
36
|
+
b"content-md5",
|
|
37
|
+
b"content-length",
|
|
38
|
+
b"content-type"])
|
|
39
|
+
result = []
|
|
40
|
+
for k in headers:
|
|
41
|
+
k_lower = k.strip().lower()
|
|
42
|
+
value = utils.convert_to_standard_string(headers[k]).strip()
|
|
43
|
+
if k_lower.startswith(http_headers.BCE_PREFIX) \
|
|
44
|
+
or k_lower in headers_to_sign:
|
|
45
|
+
str_tmp = b"%s:%s" % (utils.normalize_string(k_lower), utils.normalize_string(value))
|
|
46
|
+
result.append(str_tmp)
|
|
47
|
+
result.sort()
|
|
48
|
+
return (b'\n').join(result)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def sign(credentials, http_method, path, headers, params,
|
|
52
|
+
timestamp=0, expiration_in_seconds=1800, headers_to_sign=None):
|
|
53
|
+
"""
|
|
54
|
+
Create the authorization
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
_logger.debug('Sign params: %s %s %s %s %d %d %s' % (
|
|
58
|
+
http_method, path, headers, params, timestamp, expiration_in_seconds, headers_to_sign))
|
|
59
|
+
|
|
60
|
+
headers = headers or {}
|
|
61
|
+
params = params or {}
|
|
62
|
+
|
|
63
|
+
sign_key_info = b'bce-auth-v1/%s/%s/%d' % (
|
|
64
|
+
credentials.access_key_id,
|
|
65
|
+
utils.get_canonical_time(timestamp),
|
|
66
|
+
expiration_in_seconds)
|
|
67
|
+
sign_key = hmac.new(
|
|
68
|
+
credentials.secret_access_key,
|
|
69
|
+
sign_key_info,
|
|
70
|
+
hashlib.sha256).hexdigest()
|
|
71
|
+
|
|
72
|
+
canonical_uri = path
|
|
73
|
+
canonical_querystring = utils.get_canonical_querystring(params, True)
|
|
74
|
+
|
|
75
|
+
canonical_headers = _get_canonical_headers(headers, headers_to_sign)
|
|
76
|
+
string_to_sign = (b'\n').join([
|
|
77
|
+
http_method, canonical_uri,
|
|
78
|
+
canonical_querystring, canonical_headers
|
|
79
|
+
])
|
|
80
|
+
sign_result = hmac.new(compat.convert_to_bytes(sign_key), string_to_sign, hashlib.sha256).hexdigest()
|
|
81
|
+
# convert to bytes
|
|
82
|
+
sign_result = compat.convert_to_bytes(sign_result)
|
|
83
|
+
|
|
84
|
+
if headers_to_sign:
|
|
85
|
+
result = b'%s/%s/%s' % (sign_key_info, (b';').join(headers_to_sign), sign_result)
|
|
86
|
+
else:
|
|
87
|
+
result = b'%s//%s' % (sign_key_info, sign_result)
|
|
88
|
+
|
|
89
|
+
_logger.debug('sign_key=[%s] sign_string=[%d bytes][ %s ]' %
|
|
90
|
+
(sign_key, len(string_to_sign), string_to_sign))
|
|
91
|
+
_logger.debug('result=%s' % result)
|
|
92
|
+
return result
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Copyright 2014 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
This module provide base class for BCE service clients.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import absolute_import
|
|
17
|
+
import copy
|
|
18
|
+
from builtins import str, bytes
|
|
19
|
+
|
|
20
|
+
import baiducloud_python_sdk_core
|
|
21
|
+
from baiducloud_python_sdk_core import bce_client_configuration
|
|
22
|
+
from baiducloud_python_sdk_core.exception import BceClientError
|
|
23
|
+
from baiducloud_python_sdk_core.auth import bce_v1_signer
|
|
24
|
+
from baiducloud_python_sdk_core.http import handler
|
|
25
|
+
from baiducloud_python_sdk_core.http import bce_http_client
|
|
26
|
+
|
|
27
|
+
class BceBaseClient(object):
|
|
28
|
+
"""
|
|
29
|
+
TODO: add docstring
|
|
30
|
+
"""
|
|
31
|
+
def __init__(self, config, region_supported=True):
|
|
32
|
+
"""
|
|
33
|
+
:param config: the client configuration. The constructor makes a copy of this parameter so
|
|
34
|
+
that it is safe to change the configuration after then.
|
|
35
|
+
:type config: BceClientConfiguration
|
|
36
|
+
|
|
37
|
+
:param region_supported: true if this client supports region.
|
|
38
|
+
:type region_supported: bool
|
|
39
|
+
"""
|
|
40
|
+
self.service_id = self._compute_service_id()
|
|
41
|
+
self.region_supported = region_supported
|
|
42
|
+
# just for debug
|
|
43
|
+
self.config = copy.deepcopy(bce_client_configuration.DEFAULT_CONFIG)
|
|
44
|
+
if config is not None:
|
|
45
|
+
self.config.merge_non_none_values(config)
|
|
46
|
+
if self.config.endpoint is None:
|
|
47
|
+
self.config.endpoint = self._compute_endpoint()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _compute_service_id(self):
|
|
51
|
+
return self.__module__.split('.')[2]
|
|
52
|
+
|
|
53
|
+
def _compute_endpoint(self):
|
|
54
|
+
if self.config.endpoint:
|
|
55
|
+
return self.config.endpoint
|
|
56
|
+
if self.region_supported:
|
|
57
|
+
return b'%s://%s.%s.%s' % (
|
|
58
|
+
self.config.protocol,
|
|
59
|
+
self.service_id,
|
|
60
|
+
self.config.region,
|
|
61
|
+
baiducloud_python_sdk_core.DEFAULT_SERVICE_DOMAIN)
|
|
62
|
+
else:
|
|
63
|
+
return b'%s://%s.%s' % (
|
|
64
|
+
self.config.protocol,
|
|
65
|
+
self.service_id,
|
|
66
|
+
baiducloud_python_sdk_core.DEFAULT_SERVICE_DOMAIN)
|
|
67
|
+
|
|
68
|
+
def _send_request(self, http_method, path, headers=None, params=None, body=None, model=None):
|
|
69
|
+
return bce_http_client.send_request(
|
|
70
|
+
self.config, bce_v1_signer.sign, [handler.parse_error, handler.parse_json],
|
|
71
|
+
http_method, path, body, headers, params, model=model)
|
|
72
|
+
|
|
73
|
+
def _get_config(self, apiDict, apiName):
|
|
74
|
+
return copy.deepcopy(apiDict[apiName])
|
|
75
|
+
|
|
76
|
+
def _add_header(self, apiConfig, key, value):
|
|
77
|
+
self._set_if_nonnull(apiConfig["headers"], key, value)
|
|
78
|
+
|
|
79
|
+
def _add_query(self, apiConfig, key, value):
|
|
80
|
+
# key-only query parameter's value is "" and can satisfy non-null
|
|
81
|
+
self._set_if_nonnull(apiConfig["queries"], key, value)
|
|
82
|
+
|
|
83
|
+
def _add_path_param(self, apiConfig, key, value):
|
|
84
|
+
if value is None:
|
|
85
|
+
raise BceClientError(b"Path param can't be none.")
|
|
86
|
+
apiConfig["path"] = apiConfig["path"].replace("[" + key + "]", value)
|
|
87
|
+
|
|
88
|
+
def _set_if_nonnull(self, params, param_name=None, value=None):
|
|
89
|
+
if value is not None:
|
|
90
|
+
params[param_name] = value
|