# action 方法

## 简要

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

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

## 参数

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

| 参数                 | 类型   | 必选 | 描述                                                                                                    |
| ------------------ | ---- | -- | ----------------------------------------------------------------------------------------------------- |
| region\_id         | str  | 是  | <p>数据中心园区的可用区唯一标识符。</p><p>例如：<code>ap-shanghai-1</code></p>                                           |
| action\_id         | str  | 是  | <p>Tencent Cloud API 唯一标识符。</p><p>例如：<code>DescribeZones</code></p>                                   |
| action\_parameters | dict | 否  | <p>包含 Tencent Cloud API 参数和参数值的字典实例。</p><p>对于没有参数的 Tencent Cloud API，该参数应该被设置为 <code>None</code>。</p> |
| action\_version    | str  | 是  | <p>Tencent Cloud API 版本名称。</p><p>例如：<code>2017-03-12</code></p>                                       |

## 返回值

该方法返回包含给定 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 代码向您演示如何使用该方法：

```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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/other-products/class-and-method/universal-client/action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
