Search in sources :

Example 1 with HttpProfile

use of com.tencentcloudapi.common.profile.HttpProfile in project austin by ZhongFuCheng3y.

the class TencentSmsScript method init.

/**
 * 初始化 client
 *
 * @param account
 */
private SmsClient init(TencentSmsParam account) {
    Credential cred = new Credential(account.getSecretId(), account.getSecretKey());
    HttpProfile httpProfile = new HttpProfile();
    httpProfile.setEndpoint(account.getUrl());
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    SmsClient client = new SmsClient(cred, account.getRegion(), clientProfile);
    return client;
}
Also used : SmsClient(com.tencentcloudapi.sms.v20210111.SmsClient) Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile)

Example 2 with HttpProfile

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

the class TencentConfig method getOcrClient.

@Bean
public OcrClient getOcrClient() {
    Credential cred = new Credential(iii, kkk);
    HttpProfile httpProfile = new HttpProfile();
    httpProfile.setEndpoint("ocr.tencentcloudapi.com");
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    return new OcrClient(cred, "ap-guangzhou", clientProfile);
}
Also used : Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) OcrClient(com.tencentcloudapi.ocr.v20181119.OcrClient) Bean(org.springframework.context.annotation.Bean)

Example 3 with HttpProfile

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

the class TencentConfig method getLiveClient.

@Bean
public LiveClient getLiveClient() {
    Credential cred = new Credential(iii, kkk);
    HttpProfile httpProfile = new HttpProfile();
    httpProfile.setEndpoint("live.tencentcloudapi.com");
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    return new LiveClient(cred, "ap-chengdu", clientProfile);
}
Also used : LiveClient(com.tencentcloudapi.live.v20180801.LiveClient) Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) Bean(org.springframework.context.annotation.Bean)

Example 4 with HttpProfile

use of com.tencentcloudapi.common.profile.HttpProfile in project cmq-java-sdk by tencentyun.

the class Account method listQueue.

/**
 * list queue
 *
 * @param searchWord String
 * @param offset     int
 * @param limit      int
 * @param queueList  List<String>
 * @return totalCount int
 * @throws Exception
 * @throws CMQClientException
 * @throws CMQServerException
 */
public int listQueue(String searchWord, int offset, int limit, List<String> queueList) {
    try {
        CmqConfig cmqConfig = client.getCmqConfig();
        Credential cred = new Credential(cmqConfig.getSecretId(), cmqConfig.getSecretKey());
        String endPoint = cmqConfig.getEndpoint();
        String region = CMQTool.convertRegion(endPoint);
        DescribeCmqQueuesRequest req = new DescribeCmqQueuesRequest();
        if (offset > 0) {
            req.setOffset((long) offset);
        }
        if (limit > 0) {
            req.setLimit((long) limit);
        }
        if (null != searchWord && !"".equals(searchWord)) {
            req.setQueueName(searchWord);
        }
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint(cmqConfig.getManagerEndpoint());
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        TdmqClient client = new TdmqClient(cred, region, clientProfile);
        DescribeCmqQueuesResponse resp = client.DescribeCmqQueues(req);
        CmqQueue[] cmqQueues = resp.getQueueList();
        int totalCount = resp.getTotalCount().intValue();
        if (cmqQueues.length > 0) {
            for (CmqQueue queue : resp.getQueueList()) {
                queueList.add(queue.getQueueName());
            }
        }
        return totalCount;
    } catch (TencentCloudSDKException e) {
        System.out.println(e.toString());
    }
    return 0;
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) TdmqClient(com.tencentcloudapi.tdmq.v20200217.TdmqClient) CmqConfig(com.qcloud.cmq.entity.CmqConfig) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) DescribeCmqQueuesRequest(com.tencentcloudapi.tdmq.v20200217.models.DescribeCmqQueuesRequest) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) DescribeCmqQueuesResponse(com.tencentcloudapi.tdmq.v20200217.models.DescribeCmqQueuesResponse) CmqQueue(com.tencentcloudapi.tdmq.v20200217.models.CmqQueue)

Example 5 with HttpProfile

use of com.tencentcloudapi.common.profile.HttpProfile in project cmq-java-sdk by tencentyun.

the class Queue method getQueueAttributes.

/**
 * 获取队列属性
 *
 * @return 返回的队列属性参数
 */
public QueueMeta getQueueAttributes() {
    QueueMeta meta = new QueueMeta();
    try {
        CmqConfig cmqConfig = client.getCmqConfig();
        Credential cred = new Credential(cmqConfig.getSecretId(), cmqConfig.getSecretKey());
        String endPoint = cmqConfig.getEndpoint();
        String region = CMQTool.convertRegion(endPoint);
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint(cmqConfig.getManagerEndpoint());
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        TdmqClient client = new TdmqClient(cred, region, clientProfile);
        DescribeCmqQueueDetailRequest req = new DescribeCmqQueueDetailRequest();
        req.setQueueName(this.queueName);
        DescribeCmqQueueDetailResponse resp = client.DescribeCmqQueueDetail(req);
        CmqQueue cmqQueue = resp.getQueueDescribe();
        meta.maxMsgHeapNum = cmqQueue.getMaxMsgHeapNum().intValue();
        meta.pollingWaitSeconds = cmqQueue.getPollingWaitSeconds().intValue();
        meta.visibilityTimeout = cmqQueue.getVisibilityTimeout().intValue();
        meta.maxMsgSize = cmqQueue.getMaxMsgSize().intValue();
        meta.msgRetentionSeconds = cmqQueue.getMsgRetentionSeconds().intValue();
        meta.createTime = (int) (cmqQueue.getCreateTime() / 1000);
        meta.lastModifyTime = (int) (cmqQueue.getLastModifyTime() / 1000);
        meta.activeMsgNum = cmqQueue.getActiveMsgNum().intValue();
        meta.inactiveMsgNum = cmqQueue.getInactiveMsgNum().intValue();
        if (null != cmqQueue.getRewindMsgNum()) {
            meta.rewindmsgNum = cmqQueue.getRewindMsgNum().intValue();
        }
        if (null != cmqQueue.getMinMsgTime()) {
            meta.minMsgTime = cmqQueue.getMinMsgTime().intValue();
        }
        if (null != cmqQueue.getDelayMsgNum()) {
            meta.delayMsgNum = cmqQueue.getDelayMsgNum().intValue();
        }
        meta.rewindSeconds = cmqQueue.getRewindSeconds().intValue();
    } catch (TencentCloudSDKException e) {
        System.out.println(e.toString());
    }
    return meta;
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) TdmqClient(com.tencentcloudapi.tdmq.v20200217.TdmqClient) CmqConfig(com.qcloud.cmq.entity.CmqConfig) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) DescribeCmqQueueDetailRequest(com.tencentcloudapi.tdmq.v20200217.models.DescribeCmqQueueDetailRequest) DescribeCmqQueueDetailResponse(com.tencentcloudapi.tdmq.v20200217.models.DescribeCmqQueueDetailResponse) CmqQueue(com.tencentcloudapi.tdmq.v20200217.models.CmqQueue)

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