use of com.tencentcloudapi.cvm.v20170312.CvmClient in project tencentcloud-sdk-java-intl-en by TencentCloud.
the class DescribeZones method main.
public static void main(String[] args) {
try {
Credential cred = new Credential("secretId", "secretKey");
CvmClient client = new CvmClient(cred, "ap-guangzhou");
DescribeZonesRequest req = new DescribeZonesRequest();
DescribeZonesResponse resp = client.DescribeZones(req);
System.out.println(DescribeZonesRequest.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.cvm.v20170312.CvmClient in project tencentcloud-sdk-java by TencentCloud.
the class CredentialManager method main.
public static void main(String[] args) {
try {
// 通过凭证提供链得到一个认证对象
Credential cred = new DefaultCredentialsProvider().getCredentials();
// 实例化要请求产品(以cvm为例)的client对象,依次传入Credential、地域
CvmClient client = new CvmClient(cred, "ap-guangzhou");
// 实例化一个cvm实例信息查询请求对象,每个接口都会对应一个request对象。
DescribeInstancesRequest req = new DescribeInstancesRequest();
// 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的
// 返回的resp是一个DescribeInstancesResponse类的实例,与请求对象对应
DescribeInstancesResponse resp = client.DescribeInstances(req);
// 输出json格式的字符串回包
System.out.println(DescribeInstancesResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.cvm.v20170312.CvmClient in project tencentcloud-sdk-java by TencentCloud.
the class SignatureTest method testGetHmacSHA256.
@Test
public void testGetHmacSHA256() {
Credential cred = new Credential(System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
HttpProfile httpProfile = new HttpProfile();
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
clientProfile.setSignMethod("HmacSHA256");
httpProfile.setReqMethod("GET");
CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
try {
DescribeInstancesResponse resp = client.DescribeInstances(req);
Assert.assertTrue(resp.getTotalCount() >= 0);
} catch (TencentCloudSDKException e) {
fail(e.toString());
}
}
use of com.tencentcloudapi.cvm.v20170312.CvmClient in project tencentcloud-sdk-java by TencentCloud.
the class SignatureTest method testPostHmacSHA1.
@Test
public void testPostHmacSHA1() {
Credential cred = new Credential(System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
HttpProfile httpProfile = new HttpProfile();
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
clientProfile.setSignMethod("HmacSHA1");
httpProfile.setReqMethod("POST");
CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
try {
DescribeInstancesResponse resp = client.DescribeInstances(req);
Assert.assertTrue(resp.getTotalCount() >= 0);
} catch (TencentCloudSDKException e) {
fail(e.toString());
}
}
use of com.tencentcloudapi.cvm.v20170312.CvmClient in project tencentcloud-sdk-java by TencentCloud.
the class SignatureTest method testPostHmacSHA256.
@Test
public void testPostHmacSHA256() {
Credential cred = new Credential(System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
HttpProfile httpProfile = new HttpProfile();
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
clientProfile.setSignMethod("HmacSHA256");
httpProfile.setReqMethod("POST");
CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
try {
DescribeInstancesResponse resp = client.DescribeInstances(req);
Assert.assertTrue(resp.getTotalCount() >= 0);
} catch (TencentCloudSDKException e) {
fail(e.toString());
}
}
Aggregations