Skip to content

Commit 5ef0329

Browse files
committed
Merge "integration_2026-01-08_1102078773250" into "vod-Python-2025-01-01-online-1992-2025_12_30_15_18_00"
Conflicts: pyproject.toml
2 parents e1fcf7a + 028dc73 commit 5ef0329

File tree

124 files changed

+17546
-179
lines changed

Some content is hidden

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

124 files changed

+17546
-179
lines changed

FAQ.EN.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
### 1. Get Request and Response Types
2+
3+
Before calling a method, you can obtain the corresponding request and response structures via `param` and `return`.
4+
Taking `ecs.run_instances` as an example:
5+
6+
```python
7+
def run_instances(self, body, **kwargs): # noqa: E501
8+
"""run_instances
9+
:param RunInstancesRequest body: (required)
10+
:return: RunInstancesResponse
11+
"""
12+
```
13+
14+
### 2. Get Parameter Types for Requests and Responses
15+
16+
In the Request or Response body, you can check specific request parameters and their types via `swagger_types`.
17+
Taking `volcenginesdkecs.RunInstancesRequest` as an example, its parameter names and definitions are as follows:
18+
19+
```python
20+
swagger_types = {
21+
'auto_renew': 'bool',
22+
'auto_renew_period': 'int',
23+
'client_token': 'str',
24+
'count': 'int',
25+
'network_interfaces': 'list[NetworkInterfaceForRunInstancesInput]',
26+
'security_enhancement_strategy': 'str',
27+
'volumes': 'list[VolumeForRunInstancesInput]',
28+
......
29+
}
30+
```
31+
32+
The corresponding request body is:
33+
34+
```python
35+
volcenginesdkecs.RunInstancesRequest(
36+
instance_name="insname",
37+
network_interfaces=[volcenginesdkecs.NetworkInterfaceForRunInstancesInput(
38+
subnet_id="subnet-2d68bh73d858ozfekrm8fj",
39+
security_group_ids=["sg-2b3dq7v0ha0w2dx0eg0nhljv"],
40+
)],
41+
image_id="image-ybvz29l3da4ox5h0m9",
42+
volumes=[volcenginesdkecs.VolumeForRunInstancesInput(
43+
volume_type="ESSD",
44+
size=40,
45+
)],
46+
key_pair_name="vtable",
47+
instance_charge_type="PostPaid"
48+
)
49+
```
50+
51+
### 3. Memory Overflow Occurs
52+
53+
Check whether `Configuration._default` has been initialized.
54+
If not, each time you create a `Configuration` instance, a new logger handler will be created and added to the global logger.
55+
It is recommended to set the default configuration via `Configuration.set_default`.
56+
57+
```python
58+
configuration = volcenginesdkcore.Configuration()
59+
configuration.client_side_validation = False
60+
configuration.schema = "http" # https or http
61+
configuration.debug = False # Whether to enable debugging
62+
63+
volcenginesdkcore.Configuration.set_default(configuration)
64+
```
65+
66+
### 4. Convert Object to Dict
67+
68+
For request and response objects, you can convert them to `dict` using the `to_dict()` method.
69+
70+
### 5. View Usage Examples
71+
72+
[volcenginesdkexamples](https://github.com/volcengine/volcengine-python-sdk/tree/master/volcenginesdkexamples)
73+
74+
### 6. Convert Response Object to CamelCase Dict
75+
76+
After calling an API, the parameters in the received response object typically use PascalCase (CamelCase with the first letter capitalized). When coding with the Python SDK, since Python generally uses snake_case, you may want to convert between the SDK's snake_case fields and the documentation's CamelCase fields.
77+
78+
You can convert the response object into a CamelCase dictionary with the following code. After conversion, the field names in the dictionary will be exactly the same as those in the documentation.
79+
80+
```python
81+
import json
82+
import pprint
83+
from volcenginesdkcore.model import canonical_str
84+
85+
try:
86+
resp = api_instance.list_users(req)
87+
pprint(resp) # Response object with snake_case fields
88+
dict_resp = json.loads(json.dumps(canonical_str(resp)))
89+
pprint(dict_resp) # Response dict with CamelCase fields
90+
91+
except ApiException as e:
92+
print("Exception when calling IAMApi->ListUsers: %s\n" % e)
93+
94+
```
95+
96+
However, this is not the recommended approach. It is suggested to directly use the snake_case parameters in the response object instead of converting.

README.EN.MD

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
English | [中文](README.md)
2+
3+
# Volcengine SDK for Python
4+
5+
## Breaking Change Notice
6+
7+
Breaking change notice for Volcengine SDK for Python.
8+
9+
Affected versions: `3.0.1` and later
10+
11+
Change description:
12+
13+
To address installation failures on Windows caused by excessively long package paths, starting from `3.0.1` we shortened some overly long API model filenames under the `transitrouter` service. If you depended on those full model filenames, this change is not backward compatible. Use the shortened model name as follows:
14+
15+
```python
16+
from volcenginesdktransitrouter import TransitRouterBandwidthPackageForDescribeTransitRouterBandwidthPackagesOutput
17+
18+
var = TransitRouterBandwidthPackageForDescribeTransitRouterBandwidthPackagesOutput()
19+
```
20+
21+
Impacted service and APIs:
22+
23+
Service: `transitrouter`
24+
25+
Version: `2020-04-01`
26+
27+
APIs:
28+
29+
- DescribeTransitRouterBandwidthPackages
30+
- DescribeTransitRouterRoutePolicyTables
31+
- DescribeTransitRouterRoutePolicyEntries
32+
- DescribeTransitRouterForwardPolicyTables
33+
- DescribeTransitRouterBandwidthPackagesBilling
34+
- DescribeTransitRouterDirectConnectGatewayAttachments
35+
- DescribeTransitRouterRouteTableAssociations
36+
- DescribeTransitRouterRouteTablePropagations
37+
- DescribeTransitRouterTrafficQosQueueEntries
38+
- DescribeTransitRouterTrafficQosQueuePolicies
39+
- DescribeTransitRouterTrafficQosMarkingEntries
40+
- DescribeTransitRouterTrafficQosMarkingPolicies
41+
42+
--------
43+
44+
Affected versions: `2.0.1` and later
45+
46+
Change description:
47+
48+
Starting from `2.0.1`, the default request protocol changes from **HTTP** to **HTTPS**. After upgrading, ensure you test for compatibility risks. If you must continue using HTTP (not recommended), set `scheme` to `http`:
49+
50+
```python
51+
import volcenginesdkcore
52+
53+
configuration = volcenginesdkcore.Configuration()
54+
configuration.scheme = 'http'
55+
```
56+
57+
## Table of Contents
58+
59+
* Requirements
60+
* Install
61+
* Usage
62+
* FAQ
63+
64+
### Requirements
65+
66+
* Python version **>= 2.7**.
67+
* On Windows, installation may fail due to maximum path length limitations. Configure it as follows:
68+
69+
```
70+
1. Press Win+R, type regedit to open Registry Editor.
71+
2. Set LongPathsEnabled to 1 at:
72+
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
73+
```
74+
75+
### Install
76+
77+
Install via pip:
78+
79+
```sh
80+
pip install volcengine-python-sdk
81+
```
82+
83+
Install via [Setuptools](http://pypi.python.org/pypi/setuptools):
84+
85+
```sh
86+
python setup.py install --user
87+
```
88+
89+
(Or `sudo python setup.py install` to install for all users)
90+
91+
### Configuration Usage
92+
93+
Step 1: initialize and configure global defaults
94+
95+
```python
96+
configuration = volcenginesdkcore.Configuration()
97+
configuration.client_side_validation = True # enable client-side validation
98+
configuration.schema = "http" # https or http
99+
configuration.debug = False
100+
configuration.logger_file = "sdk.log"
101+
102+
volcenginesdkcore.Configuration.set_default(configuration)
103+
```
104+
105+
Step 2: get the client
106+
107+
```python
108+
def get_client(ak, sk, region):
109+
configuration = volcenginesdkcore.Configuration()
110+
configuration.ak = ak
111+
configuration.sk = sk
112+
configuration.region = region
113+
client = volcenginesdkautoscaling.AUTOSCALINGApi(volcenginesdkcore.ApiClient(configuration))
114+
return client
115+
```
116+
117+
### Endpoint Configuration
118+
119+
To customize the endpoint:
120+
121+
```python
122+
configuration = volcenginesdkcore.Configuration()
123+
configuration.host = 'ecs.cn-beijing-autodriving.volcengineapi.com'
124+
```
125+
126+
Standard endpoint rules:
127+
128+
| Regional Service | Global Service |
129+
|---|---|
130+
| `{service}.{region}.volcengineapi.com` <br> e.g. `ecs.cn-beijing-autodriving.volcengineapi.com` | `{service}.volcengineapi.com` <br> e.g. `iam.volcengineapi.com` |
131+
132+
Note:
133+
134+
- If the service name contains `_`, it should be converted to `-` in the endpoint. Use lowercase for all characters.
135+
136+
### SDK Example
137+
138+
```python
139+
from __future__ import print_function
140+
import volcenginesdkecs
141+
import volcenginesdkcore
142+
from pprint import pprint
143+
from volcenginesdkcore.rest import ApiException
144+
145+
if __name__ == '__main__':
146+
configuration = volcenginesdkcore.Configuration()
147+
configuration.ak = "Your AK"
148+
configuration.sk = "Your SK"
149+
configuration.region = "cn-beijing"
150+
configuration.client_side_validation = True
151+
volcenginesdkcore.Configuration.set_default(configuration)
152+
153+
api_instance = volcenginesdkecs.ECSApi()
154+
155+
try:
156+
resp = api_instance.run_instances(
157+
volcenginesdkecs.RunInstancesRequest(
158+
instance_name="insname",
159+
instance_type="ecs.g1.large",
160+
zone_id="cn-beijing-a",
161+
network_interfaces=[volcenginesdkecs.NetworkInterfaceForRunInstancesInput(
162+
subnet_id="subnet-2d68bh73d858ozfekrm8fj",
163+
security_group_ids=["sg-2b3dq7v0ha0w2dx0eg0nhljv"],
164+
)],
165+
image_id="image-ybvz29l3da4ox5h0m9",
166+
volumes=[volcenginesdkecs.VolumeForRunInstancesInput(
167+
volume_type="ESSD",
168+
size=40,
169+
)],
170+
key_pair_name="vtable",
171+
instance_charge_type="PostPaid"
172+
))
173+
pprint(resp)
174+
except ApiException as e:
175+
print("Exception when calling ECSApi->run_instances: %s\n" % e)
176+
```
177+
178+
For more examples, see: [SDK Integration Guide](./SDK_Integration.md)
179+
180+
### FAQ
181+
182+
For common issues when using the SDK, see [FAQ](FAQ.EN.md).

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
中文 | [English](README.EN.MD)
2+
13
# Volcengine SDK for Python
24

35
## 非兼容升级通知
@@ -184,4 +186,4 @@ if __name__ == '__main__':
184186

185187
### FAQ ###
186188

187-
关于 SDK 使用时碰到的常见问题,请查看 [FAQ](FAQ.md)
189+
关于 SDK 使用时碰到的常见问题,请查看 [FAQ](FAQ.md)

0 commit comments

Comments
 (0)