Search in sources :

Example 16 with HttpProfile

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

the class DescribeInstances method main.

public static void main(String[] args) {
    try {
        // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        Credential cred = new Credential("secretId", "secretKey");
        // 实例化一个http选项,可选的,没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        // get请求(默认为post请求)
        httpProfile.setReqMethod("GET");
        // 请求连接超时时间,单位为秒(默认60秒)
        httpProfile.setConnTimeout(30);
        // 指定接入地域域名(默认就近接入)
        httpProfile.setEndpoint("cvm.ap-shanghai.tencentcloudapi.com");
        // 实例化一个client选项,可选的,没有特殊需求可以跳过
        ClientProfile clientProfile = new ClientProfile();
        // 指定签名算法(默认为HmacSHA256)
        clientProfile.setSignMethod("HmacSHA256");
        clientProfile.setHttpProfile(httpProfile);
        clientProfile.setDebug(true);
        // 实例化要请求产品(以cvm为例)的client对象,clientProfile是可选的
        CvmClient client = new CvmClient(cred, "ap-shanghai", clientProfile);
        // 实例化一个cvm实例信息查询请求对象,每个接口都会对应一个request对象。
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        // 填充请求参数,这里request对象的成员变量即对应接口的入参
        // 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
        // 创建Filter对象, 以zone的维度来查询cvm实例
        Filter respFilter = new Filter();
        respFilter.setName("zone");
        respFilter.setValues(new String[] { "ap-shanghai-1", "ap-shanghai-2" });
        // Filters 是成员为Filter对象的列表
        req.setFilters(new Filter[] { respFilter });
        // 这里还支持以标准json格式的string来赋值请求参数的方式。下面的代码跟上面的参数赋值是等效的
        String params = "{\"Filters\":[{\"Name\":\"zone\",\"Values\":[\"ap-shanghai-1\",\"ap-shanghai-2\"]}]}";
        req = DescribeInstancesRequest.fromJsonString(params, DescribeInstancesRequest.class);
        // 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的
        // 返回的resp是一个DescribeInstancesResponse类的实例,与请求对象对应
        DescribeInstancesResponse resp = client.DescribeInstances(req);
        // 输出json格式的字符串回包
        System.out.println(DescribeInstancesResponse.toJsonString(resp));
        // 也可以取出单个值。
        // 你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
        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 17 with HttpProfile

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

the class EccCorrect 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("ecc.ap-beijing.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setUnsignedPayload(true);
        clientProfile.setHttpProfile(httpProfile);
        EccClient client = new EccClient(cred, "", clientProfile);
        ECCRequest req = new ECCRequest();
        final String content = "this composition content";
        req.setContent(content);
        ECCResponse res = client.ECC(req);
        System.out.println(ECCResponse.toJsonString(res));
        System.out.println(res.getRequestId());
    } catch (TencentCloudSDKException e) {
        e.printStackTrace();
    }
}
Also used : ECCRequest(com.tencentcloudapi.ecc.v20181213.models.ECCRequest) ECCResponse(com.tencentcloudapi.ecc.v20181213.models.ECCResponse) Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) EccClient(com.tencentcloudapi.ecc.v20181213.EccClient)

Example 18 with HttpProfile

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

the class EvaluationExamples method main.

public static void main(String[] args) {
    Credential cred = new Credential(SECRET_ID, SECRET_KEY);
    HttpProfile httpProfile = new HttpProfile();
    /**
     *  设置访问域名,如果需要就近部署,可以使用 soe-tencentcloudapi.com, 腾讯云将根据访问的地域解析到合适的服务器上,如果调用服务已确定地域,如华南地区
     *  可以直接使用地域域名,加快访问速度
     */
    httpProfile.setEndpoint(END_POINT);
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    SoeClient client = new SoeClient(cred, REGION, clientProfile);
    EvaluationOnce(client);
    EvaluationCn(client);
    EvaluationMutipleSeq(client);
    EvaluationAsync(client);
    EvaluationTransWithInit(client);
}
Also used : Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient)

Example 19 with HttpProfile

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

the class InitOralProcess 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);
        // 实例化要请求产品的client对象,clientProfile是可选的
        SoeClient client = new SoeClient(cred, "", clientProfile);
        InitOralProcessRequest req = new InitOralProcessRequest();
        req.setSessionId("test_123456");
        req.setRefText("bike");
        req.setWorkMode(1);
        req.setEvalMode(0);
        req.setScoreCoeff(1.0f);
        req.setServerType(0);
        InitOralProcessResponse res = client.InitOralProcess(req);
        // 输出json格式的字符串回包
        System.out.println(InitOralProcessResponse.toJsonString(res));
        // 也可以取出单个值。
        // 你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
        System.out.println(res.getRequestId());
    } catch (TencentCloudSDKException e) {
        e.printStackTrace();
    }
}
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) InitOralProcessRequest(com.tencentcloudapi.soe.v20180724.models.InitOralProcessRequest) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) InitOralProcessResponse(com.tencentcloudapi.soe.v20180724.models.InitOralProcessResponse)

Example 20 with HttpProfile

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

the class KeywordEvaluate method main.

public static void main(String[] args) throws IOException {
    try {
        Credential cred = new Credential("", "");
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("soe.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        SoeClient client = new SoeClient(cred, "", clientProfile);
        KeywordEvaluateRequest req = new KeywordEvaluateRequest();
        req.setSeqId(1);
        req.setIsEnd(1);
        req.setVoiceFileType(3);
        req.setVoiceEncodeType(1);
        req.setSessionId("test_12345_456");
        byte[] buf = Files.readAllBytes(Paths.get(AUDIO_FOR_ONCE));
        String base64Str = new sun.misc.BASE64Encoder().encode(buf);
        req.setUserVoiceData(base64Str);
        Keyword[] keywords1 = new Keyword[2];
        Keyword keyword1 = new Keyword();
        keyword1.setRefText("bike");
        keyword1.setEvalMode(0);
        keyword1.setServerType(0);
        keyword1.setScoreCoeff(1.0f);
        keyword1.setTextMode(0);
        keywords1[0] = keyword1;
        Keyword keyword2 = new Keyword();
        keyword2.setRefText("bick");
        keyword2.setEvalMode(0);
        keyword2.setServerType(0);
        keyword2.setScoreCoeff(1.0f);
        keyword2.setTextMode(0);
        keywords1[1] = keyword2;
        req.setKeywords(keywords1);
        KeywordEvaluateResponse resp = client.KeywordEvaluate(req);
        System.out.println(KeywordEvaluateResponse.toJsonString(resp));
    } catch (TencentCloudSDKException | IOException 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) Keyword(com.tencentcloudapi.soe.v20180724.models.Keyword) KeywordEvaluateRequest(com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateRequest) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) IOException(java.io.IOException) KeywordEvaluateResponse(com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateResponse)

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