<dependency><groupId>com.tencentcloudapi</groupId><artifactId>tencentcloud-sdk-java-intl-en</artifactId><!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java-intl-en and get the latest version. --><!-- Please query the latest version at https://search.maven.org/search?q=tencentcloud-sdk-java-intl-en --><version>3.0.3</version></dependency>
import com.tencentcloudapi.common.Credential;import com.tencentcloudapi.common.exception.TencentCloudSDKException;import com.tencentcloudapi.common.profile.ClientProfile;// Import the client of the corresponding product moduleimport com.tencentcloudapi.cvm.v20170312.CvmClient;// Import the request response class corresponding to the request APIimport com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest;import com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesResponse;public class DescribeInstances{public static void main(String [] args) {try{// Instantiate an authentication object. The Tencent Cloud account `secretId` and `secretKey` need to be passed in as the input parametersCredential cred = new Credential("secretId", "secretKey");// Instantiate the client object of the requested product (with CVM as an example)ClientProfile clientProfile = new ClientProfile();clientProfile.setSignMethod(ClientProfile.SIGN_TC3_256);CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);// Instantiate a request objectDescribeInstancesRequest req = new DescribeInstancesRequest();// Call the API you want to access through the client object. You need to pass in the request objectDescribeInstancesResponse resp = client.DescribeInstances(req);// A string return packet in JSON format is outputSystem.out.println(DescribeInstancesRequest.toJsonString(resp));} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
文档反馈