Python SDK 使用教程
安装
git clone https://github.com/anquanssl/python-sdk.git
cd python-sdk
python -m pip install build requests
python -m build
python -m pip install dist/anquanssl-*-py3-none-any.whl
初始化
from anquanssl.client import Client
from anquanssl.resource.product import Product
from anquanssl.resource.order import Order
client = Client("修改成 accessKeyId", "修改成 accessKeySecret")
product = Product(client)
order = Order(client)
如需 指定 API 地址:
client = Client("accessKeyId", "accessKeySecret", "https://api.orion.pki.plus/api/v1")
产品及成本列表
resp = product.product_list()
print(resp["data"]["products"])
证书下单
import uuid
from anquanssl.request.certificate_create_request import CertificateCreateRequest
req = CertificateCreateRequest()
req.unique_id = f"order_{uuid.uuid4().hex}"
req.product_id = "sslcom_dv_flex"
req.period = "annually"
req.csr = """-----BEGIN CERTIFICATE REQUEST-----
...
-----END CERTIFICATE REQUEST-----"""
req.contact_email = "contact@example.com"
req.domain_dcv = {
"example.com": "dns",
"www.example.com": "http",
}
req.notify_url = "https://app.example.com/notify"
resp = order.certificate_create(req)
service_id = resp["data"]["service_id"]
print(resp)