本文为您提供了服务端 Java SDK 的数据统计模块相关的 API 调用示例。主要包含:查询流量带宽用量。
使用前请先完成初始化,参考 初始化
接口请求参数和返回参数详见 OpenAPI:查询流量带宽用量
import com.kuaishou.vod.core.Credential;
import com.kuaishou.vod.core.HttpProfile;
import com.kuaishou.vod.openapi.client.MetricClient;
import com.kuaishou.vod.openapi.model.request.vod.DescribeDomainUsageDataRequest;
import com.kuaishou.vod.openapi.model.response.vod.DescribeDomainUsageDataResponse;
public class Demo {
public static void main(String[] args) throws Exception {
HttpProfile profile = HttpProfile.getDefault();
Credential credential = new Credential(<分配的access_key_id>, <分配的secret_key>);
MetricClient client = new MetricClient(profile, credential);
DescribeDomainUsageDataRequest request = new DescribeDomainUsageDataRequest();
request.domainName = "test.com";
request.startTime = "2022-07-31T10:20:00Z";
request.endTime = "2022-07-31T12:20:00Z";
request.interval = "day";
request.percentile = "DomesticBps";
DescribeDomainUsageDataResponse response = client.describeDomainUsageData(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());
}
}