use of com.aliyun.teaopenapi.models.Config in project lilishop by lilishop.
the class SmsUtilAliImplService method createClient.
/**
* 初始化账号Client
*
* @return Client 短信操作util
*/
public com.aliyun.dysmsapi20170525.Client createClient() {
try {
Setting setting = settingService.get(SettingEnum.SMS_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.ALI_SMS_SETTING_ERROR);
}
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);
Config config = new Config();
// 您的AccessKey ID
config.accessKeyId = smsSetting.getAccessKeyId();
// 您的AccessKey Secret
config.accessKeySecret = smsSetting.getAccessSecret();
// 访问的域名
config.endpoint = "dysmsapi.aliyuncs.com";
return new com.aliyun.dysmsapi20170525.Client(config);
} catch (Exception e) {
log.error("短信初始化错误", e);
}
return null;
}
use of com.aliyun.teaopenapi.models.Config in project cloud-sdk by mizhousoft.
the class AliyunSendSmsClient method init.
public void init(AliyunSmsProfile profile) throws CloudSDKException {
AssertUtils.notNull(profile.getAccessKeyId(), "Access key id is null.");
AssertUtils.notNull(profile.getAccessKeySecret(), "Access key secret is null.");
AssertUtils.notNull(profile.getEndpoint(), "Endpoint is null.");
Config config = new Config().setAccessKeyId(profile.getAccessKeyId()).setAccessKeySecret(profile.getAccessKeySecret()).setEndpoint(profile.getEndpoint());
try {
this.client = new com.aliyun.dysmsapi20170525.Client(config);
} catch (Exception e) {
throw new CloudSDKException("Init sms client failed.", e);
}
}
use of com.aliyun.teaopenapi.models.Config in project dingtalk-app-server by nju-softeng.
the class BaseApi method createClient.
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public com.aliyun.dingtalkdrive_1_0.Client createClient() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkdrive_1_0.Client(config);
}
use of com.aliyun.teaopenapi.models.Config in project rocketmq-connect by apache.
the class RocketMQSinkConnector method validate.
@Override
public void validate(KeyValue config) {
if (StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_ID)) || StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_SECRET)) || StringUtils.isBlank(config.getString(RocketMQConstant.NAMESRV_ADDR)) || StringUtils.isBlank(config.getString(RocketMQConstant.TOPIC))) {
throw new RuntimeException("rocketmq required parameter is null !");
}
try {
Config onsConfig = new Config().setAccessKeyId(config.getString(RocketMQConstant.ACCESS_KEY_ID)).setAccessKeySecret(config.getString(RocketMQConstant.ACCESS_KEY_SECRET));
onsConfig.endpoint = OnsUtils.parseEndpoint(config.getString(RocketMQConstant.NAMESRV_ADDR));
final Client client = new Client(onsConfig);
OnsTopicListRequest onsTopicListRequest = new OnsTopicListRequest().setTopic(config.getString(RocketMQConstant.TOPIC)).setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID));
final OnsTopicListResponse onsTopicListResponse = client.onsTopicList(onsTopicListRequest);
if (onsTopicListResponse.getBody().getData().getPublishInfoDo().isEmpty()) {
throw new RuntimeException("rocketmq required parameter topic does not exist !");
}
} catch (Exception e) {
log.error("RocketMQSinkTask | validate | error => ", e);
throw new RuntimeException(e.getMessage());
}
}
use of com.aliyun.teaopenapi.models.Config in project rocketmq-connect by apache.
the class RocketMQSourceConnector method validate.
@Override
public void validate(KeyValue config) {
if (StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_ID)) || StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_SECRET)) || StringUtils.isBlank(config.getString(RocketMQConstant.NAMESRV_ADDR)) || StringUtils.isBlank(config.getString(RocketMQConstant.TOPIC)) || StringUtils.isBlank(config.getString(RocketMQConstant.CONSUMER_GROUP))) {
throw new RuntimeException("rocketmq required parameter is null !");
}
try {
Config onsConfig = new Config().setAccessKeyId(config.getString(RocketMQConstant.ACCESS_KEY_ID)).setAccessKeySecret(config.getString(RocketMQConstant.ACCESS_KEY_SECRET));
onsConfig.endpoint = OnsUtils.parseEndpoint(config.getString(RocketMQConstant.NAMESRV_ADDR));
final Client client = new Client(onsConfig);
OnsTopicListRequest onsTopicListRequest = new OnsTopicListRequest().setTopic(config.getString(RocketMQConstant.TOPIC)).setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID));
final OnsTopicListResponse onsTopicListResponse = client.onsTopicList(onsTopicListRequest);
if (onsTopicListResponse.getBody().getData().getPublishInfoDo().isEmpty()) {
throw new RuntimeException("rocketmq required parameter topic does not exist !");
}
OnsGroupListRequest onsGroupListRequest = new OnsGroupListRequest().setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID)).setGroupId(config.getString(RocketMQConstant.CONSUMER_GROUP));
final OnsGroupListResponse onsGroupListResponse = client.onsGroupList(onsGroupListRequest);
if (onsGroupListResponse.getBody().getData().getSubscribeInfoDo().isEmpty()) {
throw new RuntimeException("rocketmq required parameter consumerGroup does not exist !");
}
} catch (Exception e) {
log.error("RocketMQSinkTask | validate | error => ", e);
throw new RuntimeException(e.getMessage());
}
}
Aggregations