Search in sources :

Example 51 with Credential

use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java by TencentCloud.

the class SignatureTest method testGetTC3HmacSHA256.

@Test
public void testGetTC3HmacSHA256() {
    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("TC3-HMAC-SHA256");
    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());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) CvmClient(com.tencentcloudapi.cvm.v20170312.CvmClient) DescribeInstancesRequest(com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest) DescribeInstancesResponse(com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesResponse) Test(org.junit.Test)

Example 52 with Credential

use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java by TencentCloud.

the class SignatureTest method testPostTC3HmacSHA256.

@Test
public void testPostTC3HmacSHA256() {
    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("TC3-HMAC-SHA256");
    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());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) CvmClient(com.tencentcloudapi.cvm.v20170312.CvmClient) DescribeInstancesRequest(com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest) DescribeInstancesResponse(com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesResponse) Test(org.junit.Test)

Example 53 with Credential

use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java-intl-en by TencentCloud.

the class CommonClientCall method main.

public static void main(String[] args) {
    try {
        Credential cred = new Credential("secretId", "secretKey");
        CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou");
        String resp = client.call("DescribeInstances", "{\"Filters\":" + "[{\"Name\":\"zone\"," + "\"Values\":[\"ap-guangzhou-1\"]}," + "{\"Name\":\"instance-charge-type\"," + "\"Values\":[\"PREPAID\",\"POSTPAID_BY_HOUR\"]}]" + "}");
        System.out.println(resp);
    } catch (TencentCloudSDKException e) {
        System.out.println(e.toString());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) CommonClient(com.tencentcloudapi.common.CommonClient)

Example 54 with Credential

use of com.tencentcloudapi.common.Credential in project Ant-Live by PinTeh.

the class TencentConfig method getVodClient.

@Bean
public VodClient getVodClient() {
    Credential cred = new Credential(iii, kkk);
    HttpProfile httpProfile = new HttpProfile();
    httpProfile.setEndpoint("vod.tencentcloudapi.com");
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    // Region公共参数,本接口不需要传递此参数。
    return new VodClient(cred, "ap-chongqing", clientProfile);
}
Also used : VodClient(com.tencentcloudapi.vod.v20180717.VodClient) Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) Bean(org.springframework.context.annotation.Bean)

Example 55 with Credential

use of com.tencentcloudapi.common.Credential in project rhythm by csfwff.

the class VerifycodeMgmtService method sendMsg.

public boolean sendMsg(String[] phoneNumber, String[] templateParam) {
    if (Latkes.getRuntimeMode().equals(Latkes.RuntimeMode.DEVELOPMENT)) {
        LOGGER.log(Level.INFO, "开发模式不真正发送短信,发送的手机号为:{},当前短信验证码为:{}", phoneNumber, templateParam);
        return true;
    } else {
        Credential cred = new Credential(Symphonys.TEN_SMS_SECRET_ID, Symphonys.TEN_SMS_SECRET_KEY);
        SmsClient client = new SmsClient(cred, Symphonys.TEN_SMS_DIYU);
        SendSmsRequest req = new SendSmsRequest();
        req.setSmsSdkAppId(Symphonys.TEN_SMS_SDK_APPID);
        req.setSignName(Symphonys.TEN_SMS_SIGN_NAME);
        req.setTemplateId(Symphonys.TEN_SMS_TEMPLATE_ID);
        req.setPhoneNumberSet(phoneNumber);
        req.setTemplateParamSet(templateParam);
        SendSmsResponse res = null;
        try {
            res = client.SendSms(req);
        } catch (TencentCloudSDKException e) {
            LOGGER.log(Level.ERROR, "Unable send SMS [phoneNumber={}, templateParam={}]", phoneNumber, templateParam);
            return false;
        }
        assert res != null;
        LOGGER.log(Level.INFO, SendSmsResponse.toJsonString(res));
        return true;
    }
}
Also used : SmsClient(com.tencentcloudapi.sms.v20210111.SmsClient) Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) SendSmsRequest(com.tencentcloudapi.sms.v20210111.models.SendSmsRequest) SendSmsResponse(com.tencentcloudapi.sms.v20210111.models.SendSmsResponse)

Aggregations

Credential (com.tencentcloudapi.common.Credential)55 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)41 ClientProfile (com.tencentcloudapi.common.profile.ClientProfile)39 HttpProfile (com.tencentcloudapi.common.profile.HttpProfile)39 CvmClient (com.tencentcloudapi.cvm.v20170312.CvmClient)12 DescribeInstancesRequest (com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest)12 DescribeInstancesResponse (com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesResponse)10 CommonClient (com.tencentcloudapi.common.CommonClient)9 Test (org.junit.Test)8 TciClient (com.tencentcloudapi.tci.v20190318.TciClient)6 SoeClient (com.tencentcloudapi.soe.v20180724.SoeClient)5 OcrClient (com.tencentcloudapi.ocr.v20181119.OcrClient)3 SmsClient (com.tencentcloudapi.sms.v20210111.SmsClient)3 HashMap (java.util.HashMap)3 CmqConfig (com.qcloud.cmq.entity.CmqConfig)2 DescribeZonesRequest (com.tencentcloudapi.cvm.v20170312.models.DescribeZonesRequest)2 DescribeZonesResponse (com.tencentcloudapi.cvm.v20170312.models.DescribeZonesResponse)2 Filter (com.tencentcloudapi.cvm.v20170312.models.Filter)2 EccClient (com.tencentcloudapi.ecc.v20181213.EccClient)2 SendSmsRequest (com.tencentcloudapi.sms.v20210111.models.SendSmsRequest)2