Search in sources :

Example 31 with HttpProfile

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

the class SubmitFullBodyClassTask method main.

public static void main(String[] args) {
    try {
        Credential cred = new Credential("", "");
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setReqMethod("POST");
        httpProfile.setConnTimeout(60);
        httpProfile.setEndpoint("tci.ap-beijing.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setUnsignedPayload(true);
        clientProfile.setHttpProfile(httpProfile);
        TciClient client = new TciClient(cred, "", clientProfile);
        SubmitFullBodyClassTaskRequest req = new SubmitFullBodyClassTaskRequest();
        req.setFileContent("https://edu-test-1253131631.cos.ap-guangzhou.myqcloud.com/aieduautotest/autotest_vedio.mp4");
        req.setFileType("vod_url");
        long lang = 0;
        req.setLang(lang);
        req.setLibrarySet(new String[] { "library_15603955264181591716" });
        req.setVocabLibNameList(new String[] { "testlib2" });
        long EncodeType = 1;
        req.setVoiceEncodeType(EncodeType);
        long FileType = 10;
        req.setVoiceFileType(FileType);
        SubmitFullBodyClassTaskResponse res = client.SubmitFullBodyClassTask(req);
        System.out.println(SubmitFullBodyClassTaskResponse.toJsonString(res));
        System.out.println(res.getRequestId());
    } catch (TencentCloudSDKException e) {
        e.printStackTrace();
    }
}
Also used : SubmitFullBodyClassTaskRequest(com.tencentcloudapi.tci.v20190318.models.SubmitFullBodyClassTaskRequest) Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SubmitFullBodyClassTaskResponse(com.tencentcloudapi.tci.v20190318.models.SubmitFullBodyClassTaskResponse) TciClient(com.tencentcloudapi.tci.v20190318.TciClient)

Example 32 with HttpProfile

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

the class UploadFiles method main.

public static void main(String[] args) {
    try {
        ClientProfile cp = new ClientProfile();
        HttpProfile hp = new HttpProfile();
        hp.setEndpoint(FileEndPoint);
        cp.setHttpProfile(hp);
        EssbasicClient client = new EssbasicClient(new Credential(Ak, Sk), "ap-guangzhou", cp);
        UploadFilesRequest request = new UploadFilesRequest();
        Caller caller = new Caller();
        caller.setApplicationId(Appid);
        caller.setOperatorId(OperatorId);
        request.setCaller(caller);
        request.setBusinessType("FLOW");
        UploadFile[] fileInfos = new UploadFile[1];
        request.setFileInfos(fileInfos);
        UploadFile file = new UploadFile();
        fileInfos[0] = file;
        file.setFileName("************");
        file.setFileBody(getFileBody());
        request.setCoverRect(false);
        UploadFilesResponse response = client.UploadFiles(request);
        System.out.println(client.gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) UploadFile(com.tencentcloudapi.essbasic.v20201222.models.UploadFile) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) Caller(com.tencentcloudapi.essbasic.v20201222.models.Caller) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) UploadFilesRequest(com.tencentcloudapi.essbasic.v20201222.models.UploadFilesRequest) EssbasicClient(com.tencentcloudapi.essbasic.v20201222.EssbasicClient) UploadFilesResponse(com.tencentcloudapi.essbasic.v20201222.models.UploadFilesResponse)

Example 33 with HttpProfile

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

the class EvaluationExample method main.

public static void main(String[] args) {
    try {
        // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        Credential cred = new Credential("...", "...");
        // 实例化一个http选项,可选的,没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        // post请求(默认为post请求)
        httpProfile.setReqMethod("POST");
        // 请求连接超时时间,单位为秒(默认60秒)
        httpProfile.setConnTimeout(60);
        // 指定接入地域域名(默认就近接入)
        httpProfile.setEndpoint("soe.ap-beijing.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setUnsignedPayload(true);
        clientProfile.setHttpProfile(httpProfile);
        HcmClient hcmClient = new HcmClient(cred, "");
        EvaluationRequest evaluationRequest = new EvaluationRequest();
        evaluationRequest.setSessionId("123456");
        evaluationRequest.setImage("iVBORw0KGgoAAAANSUhEUgAAAYsAAADSCAIAAAA0dHtXAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAa1SURBVHhe7d1hWtpMGIbRb10syPWwGjbDYvoFm9qqEELeTOYxOedf9Wor7zA3A0b87xdAKoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIpVBALoUCcikUkEuhgFwKBeRSKCCXQgG5FArIFVyo64fxA2xnnPxg/AB0EVqo6/n034fT2TbZkuG3dL1eLpfz283pm9tHz8PnPTB8CCzU9fz2zw4Z2CTbMfw2rkOUTp8n+9xQrPPl6OPPKtSwjndW0SbZhOG38J6mcZZLDaU6bqhyCnW9PFpJm6Q5w2/g8VAXGQ5UR1yKiEI9WUqbpCXDb2DlOP11OtzTvs6FmnUGtknaMPwmmtXpj2MtSb9C3RZy3kraJKsz/EY+fR+0nQOtSo9Czd8ev9kkKzL8dhbk6fdFBuMfXvJ2Gf/Xndu0UNdlB2CbZA2G39qsQJ1uFzw9uBB2+PArFyUcY2m2KdT77lj0SHFjk5QY/kYmC/XapU0zr1E4wuK0LVRtc/xhkyxi+Bt7UKjFl13OOfTu/7leo0INi1XeGx9sktcYfh/fC1W/0nKo1PhvPbD79WlUqGdz/WJYyfPjv2GTvMbw+/hcqNWuA39wNPtj7wvUv1DjpbIT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LSkUhl+jUC0pFIZfkvIylEK1ZZN0ZPgFCtWUQmH4JQrVlEJh+CUK1VRMoQC+USggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJBLoYBcCgXkUiggl0IBuRQKyKVQQC6FAnIpFJDq16//AcjLGczv/edxAAAAAElFTkSuQmCC");
        evaluationRequest.setUrl("");
        evaluationRequest.setHcmAppId("");
        EvaluationResponse evaluationResponse = hcmClient.Evaluation(evaluationRequest);
        System.out.println(evaluationResponse.getItems());
        System.out.println(evaluationResponse.getRequestId());
        System.out.println(evaluationResponse.getSessionId());
    } catch (TencentCloudSDKException e) {
        e.printStackTrace();
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) EvaluationRequest(com.tencentcloudapi.hcm.v20181106.models.EvaluationRequest) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) EvaluationResponse(com.tencentcloudapi.hcm.v20181106.models.EvaluationResponse) HcmClient(com.tencentcloudapi.hcm.v20181106.HcmClient)

Example 34 with HttpProfile

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

the class Demo method main.

/**
 *  java 调用 云api 上传日志 demo
 * @param args
 */
public static void main(String[] args) {
    // TODO 入参需要传入腾讯云账户密钥 secretId,secretKey
    Credential cred = new Credential(SECRET_ID, SECRET_KEY);
    // region 设置http选项中的参数
    HttpProfile httpProfile = new HttpProfile();
    // post请求  (默认为post请求)
    httpProfile.setReqMethod(HttpProfile.REQ_POST);
    // 指定接入地域域名(默认就近接入)
    httpProfile.setEndpoint(ENDPOINT);
    httpProfile.setRootDomain(ROOT_DOMAIN);
    // 在外网互通的网络环境下支持http协议(默认是https协议),请选择(https:// or http://)
    httpProfile.setProtocol(HttpProfile.REQ_HTTPS);
    // 设置读取超时时间,单位为秒(默认0秒)
    httpProfile.setReadTimeout(0);
    // 设置写入超时时间,单位为秒(默认0秒)
    httpProfile.setWriteTimeout(0);
    // 请求连接超时时间,单位为秒(默认60秒)
    httpProfile.setConnTimeout(HttpProfile.TM_MINUTE);
    // endregion
    // region 设置client选项中的参数
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    // 指定签名算法默认("TC3-HMAC-SHA256"),它更安全但是会轻微降低性能。
    clientProfile.setSignMethod(ClientProfile.SIGN_TC3_256);
    // 打印日志,默认是false
    clientProfile.setDebug(false);
    // endregion
    // region headers 和 body 信息
    HashMap<String, String> headers = new HashMap<String, String>();
    headers.put(X_CLS_TOPIC_ID, TOPIC);
    headers.put(X_CLS_HASH_KEY, "");
    // body lz4 压缩
    headers.put(X_CLS_COMPRESS_TYPE, LZ_4);
    byte[] body = compressedByte(getBodyInfo());
    try {
        CommonClient client = new CommonClient(PRODUCT_NAME_CLS, VERSION, cred, REGION, clientProfile);
        String resp = client.callOctetStream(UPLOAD_LOG_URL, headers, body);
        System.out.println(resp);
    } catch (TencentCloudSDKException te) {
        System.out.println(te.getMessage());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HashMap(java.util.HashMap) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) CommonClient(com.tencentcloudapi.common.CommonClient)

Example 35 with HttpProfile

use of com.tencentcloudapi.common.profile.HttpProfile 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());
    }
}
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)

Aggregations

HttpProfile (com.tencentcloudapi.common.profile.HttpProfile)41 ClientProfile (com.tencentcloudapi.common.profile.ClientProfile)40 Credential (com.tencentcloudapi.common.Credential)39 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)26 CvmClient (com.tencentcloudapi.cvm.v20170312.CvmClient)8 DescribeInstancesRequest (com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest)8 DescribeInstancesResponse (com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesResponse)8 TciClient (com.tencentcloudapi.tci.v20190318.TciClient)6 SoeClient (com.tencentcloudapi.soe.v20180724.SoeClient)5 Test (org.junit.Test)5 OcrClient (com.tencentcloudapi.ocr.v20181119.OcrClient)3 HashMap (java.util.HashMap)3 Bean (org.springframework.context.annotation.Bean)3 CmqConfig (com.qcloud.cmq.entity.CmqConfig)2 CommonClient (com.tencentcloudapi.common.CommonClient)2 Filter (com.tencentcloudapi.cvm.v20170312.models.Filter)2 EccClient (com.tencentcloudapi.ecc.v20181213.EccClient)2 SmsClient (com.tencentcloudapi.sms.v20190711.SmsClient)2 SendSmsRequest (com.tencentcloudapi.sms.v20190711.models.SendSmsRequest)2 SendSmsResponse (com.tencentcloudapi.sms.v20190711.models.SendSmsResponse)2