• CLI

sdk
  1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. JAVA
  6. Usage

Usage

Service Endpoint Configuration

When using SDK to invoke cloud service APIs, you need to obtain the address (endpoint) of each cloud service.

You can use Java SDK to automatically obtain the endpoints or manually encode the endpoints.

The following are examples of manually encoding endpoints for cloud services:

endpointResolver.addOverrideEndpoint(ServiceType.DNS, 
 "https://dns.example.com");
endpointResolver.addOverrideEndpoint(ServiceType.VOLUME_BACKUP,
 "https://vbs.example.com/v2/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.AUTO_SCALING,
 "https://as.example.com/autoscaling-api/v1/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_EYE,
 "https://ces.example.com/V1.0/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.LOAD_BALANCER,
 "https://elb.example.com/v1.0/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.MAP_REDUCE,
 "https://mrs.example.com/v1.1/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.KEY_MANAGEMENT,
 "https://kms.example.com/v1.0/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_TRACE,
 "https://cts.example.com/v1.0/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.ANTI_DDOS,
 "https://antiddos.example.com/v1/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.Notification,
 "https://smn.example.com/v2/%(project_id)s");
endpointResolver.addOverrideEndpoint(ServiceType.MessageQueue,
 "https://dms.example.com/v1.0/%(project_id)s");
  • example in the preceding code is in the Region.Cloud platform domain name format. For details about the parameters, see here.
  • In the preceding code, you do not need to replace the project_id value with the actual value.
  • Click here to obtain a complete code example of using Java SDK for reference.

Fault Locating

Add the following code to print the execution details of Java SDK:

OSFactory.enableHttpLoggingFilter(true);