You need to enable JavaScript to run this app.
导航
Python SDK
最近更新时间:2023.08.03 16:25:22首次发布时间:2022.11.17 10:15:08

本文介绍镜像仓库 Python SDK 的安装和配置,及使用 Python SDK 调用云端 API 的示例。

使用说明

仅支持 Python 2.7 及以上版本。

安装配置

通过 volcengine-python-sdk 安装。

SDK 示例

本文以查询实例接口 ListRegistries为例。

import volcenginesdkcore
import volcenginesdkcr
from pprint import pprint
from volcenginesdkcr.models.filter_for_list_registries_input import FilterForListRegistriesInput
from volcenginesdkcr.models.status_for_list_registries_input import StatusForListRegistriesInput

if __name__ == '__main__':
    configuration = volcenginesdkcore.Configuration()
    configuration.host = "API 调用地址" # API 调用地址
    configuration.ak = "AKLT****" # 您的 Access Key ID
    configuration.sk = "WTJG****" # 您的 Secret Access Key
    configuration.region = "cn-beijing"

    # create an instance of the API class
    api_instance = volcenginesdkcr.CRApi(
        volcenginesdkcore.ApiClient(configuration))

    registry = "enterprise-1"
    status_list_registry = StatusForListRegistriesInput(
        condition='Ok', phase='Running')
    filter_list_registry = FilterForListRegistriesInput(
        types=['Basic', 'Enterprise'], statuses=[status_list_registry])
    body_list_registry = volcenginesdkcr.ListRegistriesRequest(
        filter_list_registry)
    pprint(body_list_registry)
    resp_list_registry = api_instance.list_registries(
        body_list_registry)
    print("resp_list_registry\n", resp_list_registry, "\n")