final DefaultSSLContextFactoryConfig sslConfig = new ExampleDefaultSSLContextFactoryConfig();
final DefaultTransactionLogHandlerConfig logConfig = new ExampleDefaultTransactionLogHandlerConfig();
//Instantiate client instance from DNSAPIClientFactory
final DNSAPIClientFactory dnsapiClientFactory = new DNSAPIClientFactory();
DNSAPIClient client = null;
try {
client = dnsapiClientFactory.createInstanceFromDefaultProviders(config, sslConfig, logConfig);
} catch (final Exception e) {
e.printStackTrace();
System.exit(1);
}
//Create command
final ZoneGetQueryUsageCommand command =
new ZoneGetQueryUsageCommand.Builder()
.withId("<my-zone-id>")
.withSearchStartDate(LocalDateTime.now())
.withSearchEndDate(LocalDateTime.now())
.withSearchGranularity(ZoneQueryUsageGranularity.hourly)
.withSearchGroupUsage(false)
.build();
//Send command to server and receive response
try {
Response<ZoneGetQueryUsageResponse> response = client.process(command);
System.out.println("== Successful response ==");
System.out.println("== Server transaction id: " + response.getServerTransactionId());
System.out.println("== Client transaction id: " + response.getClientTransactionId());
System.out.println("== Processing time: " + response.getTransactionProcessingTime() + "ms");