引入依赖包
在您的项目中集成SDK,下载FSS OpenAPI SDK,将src/main/java/com/aliyuncs/fss_api文件夹拷贝到您项目中的对应位置。 引入以下包:
com.aliyun aliyun-java-sdk-core [version]
创建接口调用客户端实例
String regionId ="cn-shanghai"; String domain = "fssapi.cn-shanghai.aliyuncs.com"; String akId = "";//您账号的AccessKeyId String akSecret = "";//您账号的AccessKeySecret DefaultProfile.addEndpoint(regionId, "Fss-api", domain); DefaultProfile profile = DefaultProfile.getProfile(regionId, akId, akSecret); iAcsClient = DefaultAcsClient(profile);
创建检测任务
CreateScanTaskRequest createScanTaskRequest = new CreateScanTaskRequest(); createScanTaskRequest.setEmail(" ");//邮箱地址用于接收任务检测完成通知 createScanTaskRequest.setFwId("test-fwId"); createScanTaskRequest.setFwName("固件名称"); createScanTaskRequest.setFwVersion("1.0.0"); createScanTaskRequest.setFwUrl("固件的OSS链接地址"); CreateScanTaskResponse cResponse = iAcsClient.getAcsResponse(createScanTaskRequest); System.out.println("TaskId:"+ cResponse.getData().getTaskId()); System.out.println("Code:"+ cResponse.getCode()); System.out.println("Message:"+ cResponse.getMessage());
说明 OSS文件的权限应允许:读。 查询任务检测状态
QueryTaskStatusRequest queryTaskStatusRequest = new QueryTaskStatusRequest(); queryTaskStatusRequest.setTaskId(" ");//创建检测任务时,返回的任务ID QueryTaskStatusResponse response = iAcsClient.getAcsResponse(queryTaskStatusRequest); System.out.println("code:"+response.getCode()); System.out.println("description:"+response.getData().getDescription()); System.out.println("scannedRate:"+response.getData().getScannedRate()); System.out.println("ScanStatus:"+response.getData().getScanStatus());
查询任务检测结果
QueryTaskReportRequest queryTaskReportRequest = new QueryTaskReportRequest(); queryTaskReportRequest.setTaskId(" ");//创建检测任务时,返回的任务ID QueryTaskReportResponse qtResponse = iAcsClient.getAcsResponse(queryTaskReportRequest); System.out.println("reportJson:"+qtResponse.getData().getReportJson()); System.out.println("reportUrl:"+qtResponse.getData().getReportUrl());
删除任务
DeleteScanTaskRequest deleteScanTaskRequest = new DeleteScanTaskRequest(); deleteScanTaskRequest.setTaskId(" ");//创建检测任务时,返回的任务ID DeleteScanTaskResponse dResponse = iAcsClient.getAcsResponse(deleteScanTaskRequest); System.out.println("删除任务:"+dResponse.getCode()+":"+dResponse.getMessage());
查询主账号授权
QueryLicenseRequest queryLicenseRequest = new QueryLicenseRequest(); QueryLicenseResponse qlrResponse = iAcsClient.getAcsResponse(queryLicenseRequest); System.out.println("MaxCount:"+qlrResponse.getData().getMaxCount()); System.out.println("UsedCount:"+qlrResponse.getData().getUsedCount()); System.out.println("scanningCount:" + qlrResponse.getData().getScanningCount());
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。