
# 获取同步权限策略 - ShowSyncPolicy
#### 功能介绍
获取同步权限策略。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/LakeFormation/doc?api=ShowSyncPolicy)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-lakeformation/abcd.html)。
#### URI
GET /v1/{project_id}/instances/{instance_id}/policies/policy
表1路径参数 
| 参数          | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|:---|
| project_id  | 是    | String | **参数解释:** 项目编号。获取方法，请参见[获取项目ID](https://support.huaweicloud.com/api-lakeformation/lakeformation_04_0026.html)。 **约束限制:** 长度为1\~64个字符 **取值范围:** 长度为1\~64个字符 **默认取值:** 不涉及 |
| instance_id | 是    | String | **参数解释:** LakeFormation实例ID。创建实例时自动生成。例如：2180518f-42b8-4947-b20b-adfc53981a25。 **约束限制:** 最小长度为1 **取值范围:** 最小长度为1 **默认取值:** 不涉及                                           |
   
表2Query参数 
| 参数                     | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| last_known_version     | 否    | Long    | **参数解释:** 最新已知版本。 **约束限制:** 取值为-1\~2147483647 **取值范围:** 取值为-1\~2147483647 **默认取值:** 不涉及                      |
| supports_policy_deltas | 否    | Boolean | **参数解释:** 是否支持增量同步策略。 **约束限制:** 不涉及 **取值范围:** 不涉及 **默认取值:** false                                            |
| is_return_policy_data  | 否    | Boolean | **参数解释:** 是否返回权限策略数据。默认为true **约束限制:** 不涉及 **取值范围:** 不涉及 **默认取值:** true                                      |
| catalog_name           | 否    | String  | **参数解释:** catalog名称。只能包含字母、数字和下划线，且长度为1\~256个字符 **约束限制:** 长度为1\~256个字符 **取值范围:** 长度为1\~256个字符 **默认取值:** hive |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | Array of strings | **参数解释:** 租户token。 **约束限制:** 数组元素个数为1\~100 **取值范围:** 数组元素个数为1\~100 **默认取值:** 不涉及 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数                | 参数类型                                                                  | 描述                                                   |
|:---|:---|:---|
| policy_version    | Long                                                                  | **参数解释:** 策略版本     |
| policy_updateTime | String                                                                | **参数解释:** 策略更新时间   |
| policies          | Array of [Policy] objects           | **参数解释:** 权限策略信息   |
| policy_deltas     | Array of [PolicyDelta] objects | **参数解释:** 增量权限策略信息 |
   
 表5Policy 
| 参数                      | 参数类型                                                                                  | 描述                                                  |
|:---|:---|:---|
| allow_exceptions        | Array of [PolicyItem] objects                   | **参数解释:** 排除的允许策略 |
| conditions              | Array of [PolicyItemCondition] objects | **参数解释:** 条件属性    |
| create_time             | String                                                                                | **参数解释:** 创建时间    |
| created_by              | String                                                                                | **参数解释:** 创建者     |
| data_mask_policy_items  | Array of [DataMaskPolicyItem] objects   | **参数解释:** 类脱敏策略条目 |
| deny_exceptions         | Array of [PolicyItem] objects                   | **参数解释:** 拒绝排除策略  |
| deny_policy_items       | Array of [PolicyItem] objects                   | **参数解释:** 拒绝策略    |
| description             | String                                                                                | **参数解释:** 描述      |
| guid                    | String                                                                                | **参数解释:** 唯一guid  |
| id                      | Long                                                                                  | **参数解释:** 主键      |
| is_audit_enabled        | Boolean                                                                               | **参数解释:** 是否支持审计  |
| is_default_policy       | Boolean                                                                               | **参数解释:** 是否默认策略  |
| is_deny_all_else        | Boolean                                                                               | **参数解释:** 是否拒绝所有  |
| is_enabled              | Boolean                                                                               | **参数解释:** 是否启动    |
| name                    | String                                                                                | **参数解释:** 名       |
| options                 | Object                                                                                | **参数解释:** 选项      |
| policy_items            | Array of [PolicyItem] objects                   | **参数解释:** 策略信息数组  |
| policy_labels           | Array of strings                                                                      | **参数解释:** 策略便签    |
| policy_priority         | Integer                                                                               | **参数解释:** 策略优先级   |
| policy_type             | Integer                                                                               | **参数解释:** 策略类型    |
| resource_signature      | String                                                                                | **参数解释:** 资源签名    |
| resources               | Map\<String,[PolicyResource]\>              | **参数解释:** 资源      |
| row_filter_policy_items | Array of [RowFilterPolicyItem] objects | **参数解释:** 行过滤策略条目 |
| service                 | String                                                                                | **参数解释:** 服务      |
| service_type            | String                                                                                | **参数解释:** 服务类型    |
| update_time             | String                                                                                | **参数解释:** 更新时间    |
| updated_by              | String                                                                                | **参数解释:** 更新者     |
| validity_schedules      | Array of [ValiditySchedule] objects       | **参数解释:** 验证周期    |
| version                 | Long                                                                                  | **参数解释:** 版本      |
| zone_name               | String                                                                                | **参数解释:** 域       |
   
 表6PolicyDelta 
| 参数          | 参数类型                                              | 描述                                               |
|:---|:---|:---|
| policy      | [Policy] object | **参数解释:** 策略信息 |
| change_type | Integer                                           | **参数解释:** 变更类型 |
   
 表7DataMaskPolicyItem 
| 参数             | 参数类型                                                                                  | 描述                                                  |
|:---|:---|:---|
| accesses       | Array of [PolicyItemAccess] objects       | **参数解释:** 访问数组    |
| conditions     | Array of [PolicyItemCondition] objects | **参数解释:** 条件数组    |
| data_mask_info | [PolicyItemDataMaskInfo] object     | **参数解释:** 列脱敏策略信息 |
| delegate_admin | Boolean                                                                               | **参数解释:** 是否支持传递  |
| groups         | Array of strings                                                                      | **参数解释:** 用户组     |
| roles          | Array of strings                                                                      | **参数解释:** 角色      |
| users          | Array of strings                                                                      | **参数解释:** 用户      |
   
 表8PolicyItemDataMaskInfo 
| 参数             | 参数类型   | 描述                                                 |
|:---|:---|:---|
| condition_expr | String | **参数解释:** 条件表达式  |
| data_mask_type | String | **参数解释:** 列脱敏类型  |
| value_expr     | String | **参数解释:** 列脱敏表达式 |
   
 表9PolicyItem 
| 参数             | 参数类型                                                                                  | 描述                                                 |
|:---|:---|:---|
| accesses       | Array of [PolicyItemAccess] objects       | **参数解释:** 访问控制数据 |
| conditions     | Array of [PolicyItemCondition] objects | **参数解释:** 条件     |
| delegate_admin | Boolean                                                                               | **参数解释:** 是否传递   |
| groups         | Array of strings                                                                      | **参数解释:** 组      |
| roles          | Array of strings                                                                      | **参数解释:** 角色     |
| users          | Array of strings                                                                      | **参数解释:** 用户     |
   
 表10PolicyResource 
| 参数           | 参数类型             | 描述                                               |
|:---|:---|:---|
| is_excludes  | Boolean          | **参数解释:** 是否排除 |
| is_recursive | Boolean          | **参数解释:** 是否递归 |
| values       | Array of strings | **参数解释:** 值    |
   
 表11RowFilterPolicyItem 
| 参数              | 参数类型                                                                                  | 描述                                               |
|:---|:---|:---|
| accesses        | Array of [PolicyItemAccess] objects       | **参数解释:** 权限   |
| conditions      | Array of [PolicyItemCondition] objects | **参数解释:** 条件   |
| delegate_admin  | Boolean                                                                               | **参数解释:** 是否传递 |
| groups          | Array of strings                                                                      | **参数解释:** 组    |
| roles           | Array of strings                                                                      | **参数解释:** 角色   |
| row_filter_info | [PolicyItemRowFilterInfo] object   | **参数解释:** 行过滤  |
| users           | Array of strings                                                                      | **参数解释:** 用户   |
   
 表12PolicyItemAccess 
| 参数         | 参数类型    | 描述                                               |
|:---|:---|:---|
| is_allowed | Boolean | **参数解释:** 是否允许 |
| type       | String  | **参数解释:** 类型   |
   
 表13PolicyItemCondition 
| 参数     | 参数类型             | 描述                                               |
|:---|:---|:---|
| type   | String           | **参数解释:** 条件类型 |
| values | Array of strings | **参数解释:** 条件值  |
   
 表14PolicyItemRowFilterInfo 
| 参数          | 参数类型   | 描述                                                 |
|:---|:---|:---|
| filter_expr | String | **参数解释:** 行过滤表达式 |
   
 表15ValiditySchedule 
| 参数          | 参数类型                                                                                | 描述                                                |
|:---|:---|:---|
| end_time    | String                                                                              | **参数解释:** end时间 |
| recurrences | Array of [ValidityRecurrence] objects | **参数解释:** 策略递归  |
| start_time  | String                                                                              | **参数解释:** 开始时间  |
| time_zone   | String                                                                              | **参数解释:** 时间域   |
   
 表16ValidityRecurrence 
| 参数       | 参数类型                                                                      | 描述                                               |
|:---|:---|:---|
| interval | [ValidityInterval] object     | **参数解释:** 时间间隔 |
| schedule | [RecurrenceSchedule] object | **参数解释:** 周期   |
   
 表17ValidityInterval 
| 参数      | 参数类型    | 描述                                            |
|:---|:---|:---|
| days    | Integer | **参数解释:** 日 |
| hours   | Integer | **参数解释:** 时 |
| minutes | Integer | **参数解释:** 分 |
   
 表18RecurrenceSchedule 
| 参数           | 参数类型   | 描述                                                |
|:---|:---|:---|
| day_of_month | String | **参数解释:** 日期按月  |
| day_of_week  | String | **参数解释:** 日期按星期 |
| hour         | String | **参数解释:** 时     |
| minute       | String | **参数解释:** 分     |
| month        | String | **参数解释:** 月     |
| year         | String | **参数解释:** 年     |
   
**状态码：400**
表19响应Body参数 
| 参数           | 参数类型   | 描述                                                 |
|:---|:---|:---|
| error_code   | String | **参数解释:** 错误码    |
| error_msg    | String | **参数解释:** 错误描述   |
| solution_msg | String | **参数解释:** 解决方案描述 |
   
**状态码：401**
表20响应Body参数 
| 参数           | 参数类型   | 描述                                                 |
|:---|:---|:---|
| error_code   | String | **参数解释:** 错误码    |
| error_msg    | String | **参数解释:** 错误描述   |
| solution_msg | String | **参数解释:** 解决方案描述 |
   
**状态码：403**
表21响应Body参数 
| 参数         | 参数类型                                            | 描述                                               |
|:---|:---|:---|
| error      | [Error] object | **参数解释:** 错误信息 |
| error_code | String                                          | **参数解释:** 错误码  |
| error_msg  | String                                          | **参数解释:** 错误描述 |
| title      | String                                          | **参数解释:** 标题   |
   
 表22Error 
| 参数         | 参数类型   | 描述                                               |
|:---|:---|:---|
| error_code | String | **参数解释:** 错误码  |
| error_msg  | String | **参数解释:** 错误描述 |
| title      | String | **参数解释:** 标题   |
| message    | String | **参数解释:** 错误信息 |
| code       | String | **参数解释:** 状态码  |
   
**状态码：404**
表23响应Body参数 
| 参数           | 参数类型   | 描述                                                 |
|:---|:---|:---|
| error_code   | String | **参数解释:** 错误码    |
| error_msg    | String | **参数解释:** 错误描述   |
| solution_msg | String | **参数解释:** 解决方案描述 |
   
**状态码：408**
表24响应Body参数 
| 参数           | 参数类型   | 描述                                                 |
|:---|:---|:---|
| error_code   | String | **参数解释:** 错误码    |
| error_msg    | String | **参数解释:** 错误描述   |
| solution_msg | String | **参数解释:** 解决方案描述 |
   
**状态码：500**
表25响应Body参数 
| 参数           | 参数类型   | 描述                                                 |
|:---|:---|:---|
| error_code   | String | **参数解释:** 错误码    |
| error_msg    | String | **参数解释:** 错误描述   |
| solution_msg | String | **参数解释:** 解决方案描述 |
   
#### 请求示例
```
GET https://{endpoint}/v1/{project_id}/instances/{instance_id}/policies/policy
```
#### 响应示例
**状态码：200**
OK
```
{
  "policy_version" : 217,
  "policy_updateTime" : "1657788005000",
  "policies" : [ {
    "allow_exceptions" : [ ],
    "data_mask_policy_items" : [ ],
    "deny_exceptions" : [ ],
    "deny_policy_items" : [ {
      "accesses" : [ {
        "is_allowed" : true,
        "type" : "select"
      } ],
      "conditions" : [ {
        "type" : "ip-range",
        "values" : [ "*.*.*.*" ]
      } ],
      "delegate_admin" : false,
      "groups" : [ "groupD" ],
      "roles" : [ ],
      "users" : [ ]
    } ],
    "id" : 39,
    "is_audit_enabled" : true,
    "is_default_policy" : false,
    "is_deny_all_else" : false,
    "is_enabled" : true,
    "name" : "database_a.test.[**]-table_all_column",
    "options" : { },
    "policy_items" : [ {
      "accesses" : [ {
        "is_allowed" : true,
        "type" : "select"
      } ],
      "conditions" : [ ],
      "delegate_admin" : true,
      "groups" : [ "groupA" ],
      "roles" : [ ],
      "users" : [ ]
    }, {
      "accesses" : [ {
        "is_allowed" : true,
        "type" : "select"
      } ],
      "conditions" : [ ],
      "delegate_admin" : true,
      "groups" : [ "groupB" ],
      "roles" : [ ],
      "users" : [ ]
    } ],
    "policy_labels" : [ ],
    "policy_priority" : 0,
    "policy_type" : 0,
    "resources" : {
      "database" : {
        "is_excludes" : false,
        "is_recursive" : false,
        "values" : [ "database_a" ]
      },
      "column" : {
        "is_excludes" : false,
        "is_recursive" : false,
        "values" : [ "**" ]
      },
      "table" : {
        "is_excludes" : false,
        "is_recursive" : false,
        "values" : [ "test" ]
      }
    },
    "row_filter_policy_items" : [ ],
    "service" : "Hive",
    "service_type" : "hive",
    "validity_schedules" : [ ]
  } ]
}
```
**状态码：400**
Bad Request
```
{
  "error_code" : "common.01000001",
  "error_msg" : "failed to read http request, please check your input, code: 400, reason: Type mismatch., cause: TypeMismatchException"
}
```
**状态码：401**
Unauthorized
```
{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}
```
**状态码：403**
Forbidden
```
{
  "error" : {
    "code" : "403",
    "message" : "X-Auth-Token is invalid in the request",
    "error_code" : null,
    "error_msg" : null,
    "title" : "Forbidden"
  },
  "error_code" : "403",
  "error_msg" : "X-Auth-Token is invalid in the request",
  "title" : "Forbidden"
}
```
**状态码：404**
Not Found
```
{
  "error_code" : "common.01000001",
  "error_msg" : "response status exception, code: 404"
}
```
**状态码：408**
Request Timeout
```
{
  "error_code" : "common.00000408",
  "error_msg" : "timeout exception occurred"
}
```
**状态码：500**
Internal Server Error
```
{
  "error_code" : "common.00000500",
  "error_msg" : "internal error"
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK                    |
| 400 | Bad Request           |
| 401 | Unauthorized          |
| 403 | Forbidden             |
| 404 | Not Found             |
| 408 | Request Timeout       |
| 500 | Internal Server Error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-lakeformation/ErrorCode.html)。
