阅读本文,您可以获取 Java SDK 告警管理的接口调用示例,实现快速开发。
说明
本文的调用示例包含接口的部分参数。由于参数间可能存在互斥关系,在调用时,请您参考注释,进行调整。
调用接口前,请先完成 Java SDK 的安装及初始化操作。
本节为您介绍告警管理相关接口的功能和调用示例。
您可以调用 CreateImageMonitorRule 接口新建告警规则。详细的参数说明可参见 CreateImageMonitorRule 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class CreateImageMonitorRuleExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); CreateImageMonitorRuleBody body = new CreateImageMonitorRuleBody(); try { CreateImageMonitorRuleRes resp = service.createImageMonitorRule(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 DeleteImageMonitorRules 接口删除告警规则。详细的参数说明可参见 DeleteImageMonitorRules 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class DeleteImageMonitorRulesExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); DeleteImageMonitorRulesBody body = new DeleteImageMonitorRulesBody(); try { DeleteImageMonitorRulesRes resp = service.deleteImageMonitorRules(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 DeleteImageMonitorRecords 接口删除告警记录。详细的参数说明可参见 DeleteImageMonitorRecords 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class DeleteImageMonitorRecordsExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); DeleteImageMonitorRecordsBody body = new DeleteImageMonitorRecordsBody(); try { DeleteImageMonitorRecordsRes resp = service.deleteImageMonitorRecords(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 UpdateImageMonitorRule 接口更新告警规则。详细的参数说明可参见 UpdateImageMonitorRule 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class UpdateImageMonitorRuleExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); UpdateImageMonitorRuleBody body = new UpdateImageMonitorRuleBody(); try { UpdateImageMonitorRuleRes resp = service.updateImageMonitorRule(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 UpdateImageMonitorRuleStatus 接口更新告警规则状态。详细的参数说明可参见 UpdateImageMonitorRuleStatus 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class UpdateImageMonitorRuleStatusExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); UpdateImageMonitorRuleStatusBody body = new UpdateImageMonitorRuleStatusBody(); try { UpdateImageMonitorRuleStatusRes resp = service.updateImageMonitorRuleStatus(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetImageMonitorRules 接口获取所有告警规则。详细的参数说明可参见 GetImageMonitorRules 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetImageMonitorRulesExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetImageMonitorRulesQuery query = new GetImageMonitorRulesQuery(); try { GetImageMonitorRulesRes resp = service.getImageMonitorRules(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetImageAlertRecords 接口获取所有告警记录。详细的参数说明可参见 GetImageAlertRecords 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetImageAlertRecordsExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetImageAlertRecordsBody body = new GetImageAlertRecordsBody(); try { GetImageAlertRecordsRes resp = service.getImageAlertRecords(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }