Skip to main content

# 简介 # 欢迎使用京东云开发者Python工具套件(Python SDK)。使用京东云Python SDK,您无需复杂编程就可以访问京东云提供的各种服务。

Project description

为了方便您理解SDK中的一些概念和参数的含义,使用SDK前建议您先查看OpenAPI使用入门。要了解每个API的具体参数和含义,请参考程序注释或参考OpenAPI&SDK下具体产品线的API文档。

# 环境准备 #

1. 京东云Python SDK适用于Python 2.7.* 和 3.* 版本。
2. 在开始调用京东云Open API之前,需提前在京东云用户中心账户管理下的AccessKey管理页面申请accesskey和secretKey密钥对(简称AK/SK)。AK/SK信息请妥善保管,如果遗失可能会造成非法用户使用此信息操作您在云上的资源,给你造成数据和财产损失。

# SDK使用方法 #
建议使用pip安装京东云Python SDK,如下所示:

pip install -U jdcloud_sdk
您还可以下载sdk源代码自行使用。

使用源码安装您可以如下方式执行:

python setup.py install

SDK使用中的任何问题,欢迎您在Issues页面交流。

**注意:京东云并没有提供其他下载方式,请务必使用上述官方下载方式!**

调用SDK
Python SDK的调用主要分为4步:

1. 设置accessKey和secretKey
2. 创建Client
3. 设置请求参数
4. 执行请求得到响应

以下是查询云主机实例类型的调用示例

```python
# coding=utf-8
from jdcloud_sdk.core.credential import Credential
from jdcloud_sdk.services.vm.client.VmClient import VmClient
from jdcloud_sdk.services.vm.apis.DescribeInstanceTypesRequest \
import DescribeInstanceTypesParameters, DescribeInstanceTypesRequest

access_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
secret_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
credential = Credential(access_key, secret_key)
client = VmClient(credential)

try:
parameters = DescribeInstanceTypesParameters('cn-north-1')
request = DescribeInstanceTypesRequest(parameters)
resp = client.send(request)
if resp.error is not None:
print(resp.error.code, resp.error.message)
print(resp.result)
except Exception as e:
print(e)
# 错误处理
```

如果需要设置额外的header,例如要调用开启了MFA操作保护的接口,需要传递x-jdcloud-security-token,则按照如下方式:
```python
parameters = DeleteInstanceParameters('cn-north-1', 'i-xxx')
header = {'x-jdcloud-security-token': 'xxx'}
request = DeleteInstanceRequest(parameters, header)
```

Home-page: https://github.com/jdcloud-api/jdcloud-sdk-python
Author: JDCloud API Gateway Team
Author-email: UNKNOWN
License: Apache License V2.0
Description: UNKNOWN
Platform: UNKNOWN

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jdcloud_sdk-1.5.4.tar.gz (354.1 kB view details)

Uploaded Source

File details

Details for the file jdcloud_sdk-1.5.4.tar.gz.

File metadata

  • Download URL: jdcloud_sdk-1.5.4.tar.gz
  • Upload date:
  • Size: 354.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.2.7 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.5

File hashes

Hashes for jdcloud_sdk-1.5.4.tar.gz
Algorithm Hash digest
SHA256 1cb2f5b4f64cc76978a4489832f11bf1320a4ed3ffb7b8615ec5724cf19fec76
MD5 1ade38b8c6bd172dead0b4cb5880ce2c
BLAKE2b-256 fb83aad1cf1061f143ef3db1346a6aa9de7929147302de9a90c339d2e4bda7fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page