
# 修改策略组应用对象 - BatchUpdateTargetOfPolicyGroup
#### 功能介绍
批量增加、删除应用对象到指定策略组。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/Workspace/doc?api=BatchUpdateTargetOfPolicyGroup)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-workspace/workspace_09_0128.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                                  | 访问级别  | 资源类型（\*为必须）    | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | workspace:policyGroups:updateTargets | Write | policyGroup \* | -   | -  | -      |
  | workspace:policyGroups:updateTargets | Write | desktop        | -   | -  | -      |
  | workspace:policyGroups:updateTargets | Write | desktopPool    | -   | -  | -      |
  | workspace:policyGroups:updateTargets | Write | user           | -   | -  | -      |
  | workspace:policyGroups:updateTargets | Write | userGroup      | -   | -  | -      |
  | workspace:policyGroups:updateTargets | Write | appGroup       | -   | -  | -      |
     
  
 
#### URI
PUT /v2/{project_id}/policy-groups/{policy_group_id}/targets
表1路径参数 
| 参数              | 是否必选 | 参数类型   | 描述     |
|:---|:---|:---|:---|
| project_id      | 是    | String | 项目ID。  |
| policy_group_id | 是    | String | 策略组id。 |
   
#### 请求参数
表2请求Body参数 
| 参数     | 是否必选 | 参数类型                                                                       | 描述    |
|:---|:---|:---|:---|
| add    | 否    | Array of [Target] objects | 添加应用。 |
| delete | 否    | Array of [Target] objects | 删除应用。 |
   
 表3Target 
| 参数            | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| target_id     | 否    | String | 对象ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| target_name   | 否    | String | 对象名称，长度不能超过64个字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| target_type   | 否    | String | 对象类型。 - INSTANCE：表示桌面。   - USER：表示用户。   - USERGROUP：表示用户组。   - CLIENTIP：终端IP地址。   - OU：组织单元。   - DESKTOPSPOOL：表示桌面池。   - ALL：表示所有桌面。   - DESKTOP_TAG：表示桌面标签。    target_id：为桌面的SID。 target_name：为桌面name。 target_id：为用户ID。 target_name：为用户name。 target_id：为用户组ID。 target_name：为用户组name。 target_id：终端IP地址。 target_name：终端IP地址。 target_id：OUID。 target_name：OU名称。 target_id：为桌面池的ID。 target_name：为桌面池name。 target_id：default-apply-all-targets。 target_name：All-Targets。 target_id：标签的key\|标签的value。 target_name：标签的key\|标签的value。 |
| target_domain | 否    | String | 对象所在域。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
   
#### 响应参数
**状态码：200**
正常。
**状态码：400**
表4响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：401**
表5响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：403**
表6响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：404**
表7响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：405**
表8响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：500**
表9响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：503**
表10响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
#### 请求示例
```
PUT /v2/29dfe82ada564ac2b927e1ff036d9a9b/policy-groups/401a23865cae63f3015cceb9affe0049/targets
{
  "add" : [ {
    "target_id" : "xxxx-xxxx-xxxx-xxxx",
    "target_type" : "USER",
    "target_name" : "All-Targets-123"
  } ],
  "delete" : [ {
    "target_id" : "xxxx-xxxx-xxxx-xxxx",
    "target_type" : "USER",
    "target_name" : "All-Targets-456"
  } ]
}
```
#### 响应示例
**状态码：200**
正常。
```
null
```
#### 状态码
| 状态码 | 描述                      |
|:---|:---|
| 200 | 正常。                     |
| 400 | 由于包含语法错误，当前请求无法被服务器理解。  |
| 401 | 鉴权失败。                   |
| 403 | 没有操作权限。                 |
| 404 | 找不到资源。                  |
| 405 | 请求中指定的方法不被允许。           |
| 500 | 服务内部错误，具体返回错误码请参见错误码说明。 |
| 503 | 服务不可用。                  |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-workspace/ErrorCode.html)。
