
# 获取数据源中的表 - ListDataTables_offline
#### 功能介绍
获取数据源中的表。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-dataartsstudio/making_request.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-dataartsstudio/abcd.html)。
- 如果使用身份策略授权，当前API调用无需身份策略权限。
 
#### URI
GET /v2/{project_id}/{connection_id}/datatables
表1路径参数 
| 参数            | 是否必选 | 参数类型   | 描述                                                                                                    |
|:---|:---|:---|:---|
| project_id    | 是    | String | 项目ID，获取方法请参见[项目ID和账号ID](https://support.huaweicloud.com/api-dataartsstudio/projectid_accountid.html)。 |
| connection_id | 是    | String | 数据连接id，可通过[数据连接列表](https://support.huaweicloud.com/api-dataartsstudio/ListDataconnections.html)中获取。   |
   
表2Query参数 
| 参数            | 是否必选 | 参数类型   | 描述        |
|:---|:---|:---|:---|
| database_name | 是    | String | 数据库名称。    |
| table_name    | 否    | String | 指定查询表的名称。 |
| limit         | 否    | String | 数据条数限制。   |
| offset        | 否    | String | 偏移量。      |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token，使用[Token认证](https://support.huaweicloud.com/api-dataartsstudio/dataartsstudio_02_0010.html)时必选。通过调用IAM服务的"获取用户Token"接口获取响应消息头中X-Subject-Token的值。 |
| workspace    | 是    | String | 数据所在空间的id值。                                                                                                                                              |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数          | 参数类型                                                                        | 描述           |
|:---|:---|:---|
| total_count | Integer                                                                     | 当前数据库中表的记录数。 |
| tables      | Array of [TablesList] objects | 表的列表。        |
   
 表5TablesList 
| 参数            | 参数类型    | 描述                  |
|:---|:---|:---|
| table_name    | String  | 表名称。                |
| table_id      | String  | 数据表的id信息。           |
| table_name_cn | String  | 表的中文名称。             |
| columns       | String  | 表中字段。               |
| dw_id         | String  | 数据连接id。             |
| dw_name       | String  | 数据连接名称。             |
| dw_type       | String  | 数据连接类型。             |
| database_name | String  | 数据库名称。              |
| schema_name   | String  | schema名称。           |
| life_cycle    | Integer | 表的生命周期。             |
| description   | String  | 表的描述。               |
| user_id       | String  | 用户id，可在IAM侧用户信息中查询。 |
| user_name     | String  | 用户名称。               |
| project_id    | String  | 数据连接id。             |
| create_time   | String  | 表的创建时间。             |
| table_size    | Integer | 表的大小。               |
| total_count   | Integer | 当前查询条件下表的总记录数。      |
| is_valid      | Integer | 表是否合规。              |
| extra_setting | String  | 表的额外设置。             |
| partitioned   | Boolean | 是否进行数据分区。           |
   
**状态码：400**
表6响应Body参数 
| 参数         | 参数类型   | 描述       |
|:---|:---|:---|
| error_msg  | String | 返回的错误信息。 |
| error_code | String | 返回的错误码。  |
   
**状态码：500**
表7响应Body参数 
| 参数         | 参数类型   | 描述       |
|:---|:---|:---|
| error_msg  | String | 返回的错误信息。 |
| error_code | String | 返回的错误码。  |
   
#### 请求示例
无
#### 响应示例
**状态码：200**
Success，返回查询的表的列表。
```
{
  "tables" : [ {
    "description" : null,
    "table_id" : "NativeTable-9b18c0ad6ef5404caef4e6cbaccdae6f-postgres-dm_autotest-kuaallfuhe01",
    "table_name" : "kuaallfuhe01",
    "table_name_cn" : null,
    "columns" : null,
    "dw_id" : "9b18c0ad6ef5404caef4e6cbaccdae6f",
    "dw_name" : "dws_xiaoyu",
    "dw_type" : "DWS",
    "database_name" : "postgres",
    "schema_name" : "dm_autotest",
    "life_cycle" : 0,
    "user_id" : "user_id_example",
    "user_name" : null,
    "project_id" : null,
    "create_time" : null,
    "table_size" : 0,
    "total_count" : 15,
    "is_valid" : 1,
    "extra_setting" : null,
    "partitioned" : true
  } ],
  "total_count" : 15
}
```
**状态码：400**
BadRequest。
```
{
  "error_code" : "DAYU.4402",
  "error_msg" : "The operation failed， detail msg {0}."
}
```
**状态码：500**
Internal Server Error。
```
{
  "error_code" : "DAYU.3531",
  "error_msg" : "Internal server error: {0}"
}
```
#### 状态码
| 状态码 | 描述                     |
|:---|:---|
| 200 | Success，返回查询的表的列表。     |
| 400 | BadRequest。            |
| 500 | Internal Server Error。 |
   
