# huaweicloud-UpdateValueList-java
**Repository Path**: HuaweiCloudDeveloper/huaweicloud-update-value-list-java
## Basic Information
- **Project Name**: huaweicloud-UpdateValueList-java
- **Description**: 用于存放修改引用表的示例代码
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master-dev
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-07-19
- **Last Updated**: 2025-06-16
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 功能介绍
华为云提供了Web应用防火墙SDK,您可以直接集成使用服务端SDK来调用Web应用防火墙的相关API,从而实现对引用表的快速操作。 该示例展示了如何通过java版SDK修改引用表。
修改过后的引用表会同步给CC攻击防护规则、精准访问防护规则和网站反爬虫防护规则使用。当配置CC攻击防护规则、精准访问防护规则和网站反爬虫防护规则时,“条件列表”中的“逻辑”关系选择“包含任意一个”、“不包含所有”、“等于任意一个”、“不等于所有”、“前缀为任意一个”、“前缀不为所有”、“后缀为任意一个”或者“后缀不为所有”时,可在“内容”的下拉框中选择适合的引用表名称。
**注意:入门版和标准版不支持该功能。**
## 前置条件
- 1、获取华为云开发工具包(SDK),您也可以查看安装JAVA SDK。
- 2、要使用华为云 Java SDK,您需要拥有华为云账号以及该账号对应的 Access Key(AK)和 Secret Access Key(SK)。
- 3、华为云 Java SDK 支持 **Java JDK 1.8** 及其以上版本。
### SDK获取和安装
您可以通过Maven配置所依赖的主机迁移服务SDK
```xml
com.huaweicloud.sdk
huaweicloud-sdk-all
${sdk-version}
```
## 示例代码
```java
public class ValuelistDemo {
private static final Logger logger = LoggerFactory.getLogger(ValuelistDemo.class);
public static void main(String[] args) {
ICredential auth = new BasicCredentials()
.withAk("")
.withSk("");
WafClient client = WafClient.newBuilder()
.withCredential(auth)
.withRegion(WafRegion.valueOf("cn-south-1"))
.build();
try {
UpdateValueListResponse updateValueListResponse = updateValuelist(client);
} catch (ConnectionException e) {
logger.error("A connect timeout exception occurs while the WAF performs some certificate-related operations, exception: {}", e);
} catch (RequestTimeoutException e) {
logger.error("A request timeout exception occurs while the WAF performs some certificate-related operations, exception: {}", e);
} catch (ServiceResponseException e) {
logger.error("there is service response error, exception: {}", e);
logger.error("HttpStatusCode: {}", e.getHttpStatusCode());
logger.error("RequestId: {}", e.getRequestId());
logger.error("ErrorCode: {}", e.getErrorCode());
logger.error("ErrorMsg: {}", e.getErrorMsg());
}
}
private static UpdateValueListResponse updateValuelist(WafClient client) {
// 初始化引用表的值
List values = new ArrayList<>();
values.add("/url2");
// 初始引用表信息
UpdateValueListRequest updateValueListRequest = new UpdateValueListRequest()
.withValuelistid("Valuelistid")
.withBody(new UpdateValueListRequestBody()
.withName("demo")
.withType(UpdateValueListRequestBody.TypeEnum.URL)
.withValues(values));
// 更新引用表
UpdateValueListResponse updateValueListResponse = client.updateValueList(updateValueListRequest);
logger.info(updateValueListResponse.toString());
return updateValueListResponse;
}
}
```
## 参考
更多信息请参考[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/WAF/doc?api=UpdateValueList)
## 修订记录
| 发布日期 | 文档版本 | 修订说明 |
| :--------: | :------: | :----------: |
| 2023-07-20 | 1.0 | 文档首次发布 |