action 方法

命名空间和模块:tencent.cloud.core.client.UniversalClient

简要

调用当前客户端所绑定 Tencent Cloud 产品的指定 Tencent Cloud API 并获得结果。

def action(self,
    region_id: str,
    action_id: str,
    action_parameters: dict,
    action_version: str,
) -> dict

参数

该方法具有以下参数,其参数、参数类型和参数描述如下:

参数

类型

必选

描述

region_id

str

数据中心园区的可用区唯一标识符。

例如:ap-shanghai-1

action_id

str

Tencent Cloud API 唯一标识符。

例如:DescribeZones

action_parameters

dict

包含 Tencent Cloud API 参数和参数值的字典实例。

对于没有参数的 Tencent Cloud API,该参数应该被设置为 None

action_version

str

Tencent Cloud API 版本名称。

例如:2017-03-12

返回值

该方法返回包含给定 Tencent Cloud API 响应结构的字典实例。

异常

该方法可能会主动引发以下异常类型:

ValueError

参数值或类型不符合预期。

RequestError

Tencent Cloud SDK for Python 请求给定 Tencent Cloud API 时出错,这可能是由于网络原因所引起的。

ResponseError

Tencent Cloud SDK for Python 解析给定 Tencent Cloud API 响应内容结构时出错,这可能是由于响应内容不符合预期所引起的(例如使用非 Tencent Cloud API v3 版本)。

ActionError

给定 Tencent Cloud API 遇到错误,这可能是由于访问凭据无效、参数值或类型不符合预期等引起。

示例

接下来我们将通过一段 Python 代码向您演示如何使用该方法:

action_result: dict = virtual_machine_client.action(
    region_id = 'ap-shanghai',
    action_id = 'DescribeZones',
    action_version = '2017-03-12'
)

适用于

Tencent Cloud SDK for Python

基础软件包:tencent-cloud-sdk-core >= 0.1.1

最后更新于