• Cloud Container Engine

  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. APIs
  5. Authenticating Requests
  6. AK/SK Authentication
  7. Sample Code

Sample Code

Sample code shows how to sign a request and use an HTTP client to send an HTTPS request: Sample code is classified in to the following three types to demonstrate request signing and HTTP request sending.
  • AccessService: indicates the abstract class that converts the GET, POST, PUT, and DELETE methods in to the access method.
  • Demo: indicates the execution entry used to simulate GET, POST, PUT, and DELETE request sending.
  • AccessServiceImpl: indicates the implementation of the access method. Code required for API gateway communication is in the access method.

You can obtain sample code package SdkDemo.zip from https://apig-demo.obs.eu-de.otc.t-systems.com/java/SdkDemo.zip.

Decompress the package to obtain the following files in SdkDemo\src\main\java\com\cloud\apigateway\sdk\demo:
  • AccessService.java
  • Demo.java
  • AccessServiceImpl.java

For details about region and serviceName in the sample code, see Regions and Endpoints.

  1. Parameters URIAKSK, and HTTP METHOD are mandatory.
  2. You can use the request.addHeader() method to add header information.