Skip to main content

sdk-python

安装

pip install requests

pip install rsa

Crypto安装

1.pip install pycryptodome

2.python安装路径下找到文件夹\Lib\site-packages\crypto, 将crypto重命名为Crypto

biz_model和params_model使用场景:

GET请求 使用biz_model 如:rpa_tasks_results_get.py POST、 PUT、DELETE请求: Body参数 使用biz_model 如:rpa_plans_post.py Query参数 使用params_model 如:rpa_plans_drivers_post.py, rpa_plans_drivers_delete.py

2023.5.16

更新OpenClient.py、RequestTypes.py、BaseRequest.py。 支持流式接口调用

2022.5.26

更新OpenClient.py、RequestTypes.py、BaseRequest.py。 通过参数params_model = {}设置url携带参数(GET请求以外有效)

接口封装步骤

比如查询计划详情接口

  • 接口名:/rpa/plans
  • 参数:planId 要查询的计划Id
  • 返回信息
{
        "msg": "SUCCESS",
        "code": "0",
        "data": {
            "name": "任务名称repeat",
            "platformId": "0",
            "actionType": "REPEAT_BY_WEEK"
        },
        "requestId": "765656",
}

针对这个接口,封装步骤如下:

1.在model包下新建一个类,定义业务参数

class RpaPlansGetModel:
    """查询计划详情"""

    # 要查询的计划Id
    planId = None

2.在request包下新建一个请求类,继承BaseRequest

重写get_method()方法,填接口名。

重写get_request_type()方法,填接口请求方式。

class RpaPlansGetRequest(BaseRequest):
    """查询计划详情"""

    def __init__(self):
        BaseRequest.__init__(self)

    def get_method(self):
        return '/rpa/plans'

    def get_request_type(self):
        return RequestTypes.GET

3.调用方式

    
# 自用API-查询计划详情
def rpa_plans_get():
    # 创建请求客户端
    client = OpenClient(Config.app_id, Config.private_key, Config.url)

    # 创建请求
    request = RpaPlansGetRequest()
    # 请求参数,方式一
    model = RpaPlansGetModel()
    model.planId = 5070
    request.biz_model = JsonUtil.to_json_string(model)
    # 请求参数,方式二
    # request.biz_model = {
    #     'planId': 5070
    # }

    # 调用请求
    response = client.execute(request, user_token='填写user_token')

    if response.is_success():
        print('response: ', response)
        print('data: ', response.data)
    else:
        print("response: ", response)
        print('请求失败,request_id:%s, code:%s, msg:%s, sub_code:%s, sub_msg:%s' % \
              (response.request_id, response.code, response.msg, response.sub_code, response.sub_msg))

流式接口调用方式

        # 调用请求,设置stream=True
        response = client.execute(request, app_token='填写app_token', stream=True)
        # 迭代获取流结果
        for item in response.iter_content():
            if item.is_success():
                print(item.get_content())
                print(item.data)
            else:
                print('请求失败,request_id:%s, code:%s, msg:%s, sub_code:%s, sub_msg:%s' %
                      (item.request_id, item.code, item.msg, item.sub_code, item.sub_msg))

Metadata

Release files for ziniao-oapi 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ziniao-oapi 0.1.1
File Size Uploaded Provenance
ziniao_oapi-0.1.1.tar.gz 8.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ziniao-oapi 0.1.1
File Interpreter ABI Platform
ziniao_oapi-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / ziniao_oapi-0.1.1.tar.gz

Download URL ziniao_oapi-0.1.1.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
711365a567301b1b46f0e7aebc7ab28b45a67987a97932bd5d937f585619e4cb
BLAKE2b-256 checksum
How to use checksums
e96a90240e89050b9521d5863c181c67079dac17139412ec899546a5852620b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Release files / ziniao_oapi-0.1.1-py3-none-any.whl

Download URL ziniao_oapi-0.1.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1ff4f704d9c94418bb73fffb5e77725ecc0ae356d6846667a7a7dbda9ce3642
BLAKE2b-256 checksum
How to use checksums
5e98e45cb9f55b120fc90ddb5c3dbf5d439ab4fcdd826abcc6d17bd53839d50c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Security for ziniao-oapi 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page