Search in sources :

Example 31 with Credential

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

the class CommonClientRequest 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");
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        String resp = client.commonRequest(req, "DescribeInstances");
        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) DescribeInstancesRequest(com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest) CommonClient(com.tencentcloudapi.common.CommonClient)

Example 32 with Credential

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

the class DescribeInstances method main.

public static void main(String[] args) {
    try {
        Credential cred = new Credential("your-secret-id", "your-secret-key");
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setReqMethod("GET");
        httpProfile.setConnTimeout(30);
        httpProfile.setEndpoint("cvm.ap-shanghai.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setSignMethod("HmacSHA256");
        clientProfile.setHttpProfile(httpProfile);
        CvmClient client = new CvmClient(cred, "ap-shanghai", clientProfile);
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        Filter respFilter = new Filter();
        respFilter.setName("zone");
        respFilter.setValues(new String[] { "ap-shanghai-1", "ap-shanghai-2" });
        req.setFilters(new Filter[] { respFilter });
        DescribeInstancesResponse resp = client.DescribeInstances(req);
        System.out.println(DescribeInstancesResponse.toJsonString(resp));
        System.out.println(resp.getTotalCount());
    } catch (TencentCloudSDKException e) {
        System.out.println(e.toString());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) Filter(com.tencentcloudapi.cvm.v20170312.models.Filter) 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)

Example 33 with Credential

use of com.tencentcloudapi.common.Credential 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());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) DescribeZonesRequest(com.tencentcloudapi.cvm.v20170312.models.DescribeZonesRequest) DescribeZonesResponse(com.tencentcloudapi.cvm.v20170312.models.DescribeZonesResponse) CvmClient(com.tencentcloudapi.cvm.v20170312.CvmClient)

Example 34 with Credential

use of com.tencentcloudapi.common.Credential in project MaxKey by dromara.

the class SmsOtpAuthnTencentCloud method produce.

@Override
public boolean produce(UserInfo userInfo) {
    // 手机号
    String mobile = userInfo.getMobile();
    if (mobile != null && !mobile.equals("")) {
        try {
            Credential cred = new Credential(secretId, secretKey);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile);
            String token = this.genToken(userInfo);
            String params = "{\"PhoneNumberSet\":[\"" + mobile + "\"]," + "\"TemplateID\":\"" + templateId + "\",\"Sign\":\"" + sign + "\"," + "\"TemplateParamSet\":[\"" + token + "\",\"" + this.interval + "\"]," + "\"SmsSdkAppid\":\"" + smsSdkAppid + "\"}";
            SendSmsRequest req = SendSmsRequest.fromJsonString(params, SendSmsRequest.class);
            SendSmsResponse resp = client.SendSms(req);
            logger.debug("responseString " + SendSmsRequest.toJsonString(resp));
            if (resp.getSendStatusSet()[0].getCode().equalsIgnoreCase("Ok")) {
                this.optTokenStore.store(userInfo, token, userInfo.getMobile(), OtpTypes.SMS);
                return true;
            }
        } catch (Exception e) {
            logger.error(" produce code error ", e);
        }
    }
    return false;
}
Also used : SmsClient(com.tencentcloudapi.sms.v20190711.SmsClient) Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SendSmsRequest(com.tencentcloudapi.sms.v20190711.models.SendSmsRequest) SendSmsResponse(com.tencentcloudapi.sms.v20190711.models.SendSmsResponse)

Example 35 with Credential

use of com.tencentcloudapi.common.Credential in project cloud-sdk by mizhousoft.

the class SensitiveWordsRecognitionServiceImpl method init.

public void init(NLPProfile profile) throws CloudSDKException {
    NLPProfileValidator.validate(profile);
    Credential cred = new Credential(profile.getAccessKey(), profile.getSecretKey());
    HttpProfile httpProfile = new HttpProfile();
    httpProfile.setEndpoint(profile.getEndpoint());
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    NlpClient client = new NlpClient(cred, profile.getRegion(), clientProfile);
    this.nlpClient = client;
    LOG.info("Init nlp client successfully.");
}
Also used : Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) NlpClient(com.tencentcloudapi.nlp.v20190408.NlpClient)

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