use of com.aliyuncs.IAcsClient in project jointware by isdream.
the class AliyunECSAPIExample method main.
/**
* @param args
* @throws ClientException
* @throws ServerException
*/
public static void main(String[] args) throws ServerException, ClientException {
IClientProfile profile = DefaultProfile.getProfile(REGINE_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
IAcsClient client = new DefaultAcsClient(profile);
DescribeZonesRequest request = new DescribeZonesRequest();
DescribeZonesResponse response = client.getAcsResponse(request);
System.out.println(response.getZones().get(0).getZoneId());
DescribeInstancesRequest dur = new DescribeInstancesRequest();
for (Instance ins : client.getAcsResponse(dur).getInstances()) {
System.out.println(ins.getInstanceName() + "\t:" + ins.getRegionId());
}
}
use of com.aliyuncs.IAcsClient in project fc-java-sdk by aliyun.
the class PopClient method openFCService.
public OpenFunctionComputeResponse openFCService(Config config, OpenFunctionComputeRequest request) throws ClientException, ServerException {
request.validate();
try {
String accessKeyId = config.getAccessKeyID();
String accessSecret = config.getAccessKeySecret();
DefaultProfile profile = null;
if (StringUtils.isBlank(config.getSecurityToken())) {
profile = DefaultProfile.getProfile(OPEN_FC_SERVICE_REGION, accessKeyId, accessSecret);
} else {
String sToken = config.getSecurityToken();
profile = DefaultProfile.getProfile(OPEN_FC_SERVICE_REGION, accessKeyId, accessSecret, sToken);
}
OpenFcServiceRequest openFCServiceRequest = new OpenFcServiceRequest();
IAcsClient client = new DefaultAcsClient(profile);
openFCServiceRequest.setSysEndpoint(OPEN_FC_SERVICE_ENDPOINT);
OpenFcServiceResponse openFCServiceResponse = client.getAcsResponse(openFCServiceRequest);
OpenFunctionComputeResponse response = new OpenFunctionComputeResponse();
response.setRequestId(openFCServiceResponse.getRequestId());
response.setOrderId(openFCServiceResponse.getOrderId());
return response;
} catch (com.aliyuncs.exceptions.ClientException e) {
if (StringUtils.contains(e.getErrMsg(), "已开通")) {
OpenFunctionComputeResponse response = new OpenFunctionComputeResponse();
response.setRequestId(e.getRequestId());
response.setCode(ERROR_CODE_ORDER_OPENED);
response.setMsg("You have subscribed FunctionCompute, please proceed to FC console and start using it.");
return response;
}
throw new ClientException(e.getErrCode(), e.getErrMsg(), e.getRequestId());
}
}
use of com.aliyuncs.IAcsClient in project ranch by heisedebaise.
the class AliyunServiceImpl method getIAcsClient.
@Override
public IAcsClient getIAcsClient(String appCode) {
if (map.containsKey(appCode))
return map.get(appCode);
AliyunModel aliyun = aliyunDao.find(appCode);
if (aliyun == null)
return null;
IAcsClient acsClient = new DefaultAcsClient(DefaultProfile.getProfile("cn-hangzhou", aliyun.getKeyId(), aliyun.getKeySecret()));
map.put(appCode, acsClient);
return acsClient;
}
use of com.aliyuncs.IAcsClient in project jointware by isdream.
the class ECSMain method main.
/**
* @param args
* @throws ClientException
* @throws ServerException
*/
public static void main(String[] args) throws ServerException, ClientException {
IClientProfile profile = DefaultProfile.getProfile(REGINE_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
IAcsClient client = new DefaultAcsClient(profile);
DescribeZonesRequest request = new DescribeZonesRequest();
DescribeZonesResponse response = client.getAcsResponse(request);
System.out.println(response.getZones().get(0).getZoneId());
DescribeInstancesRequest dur = new DescribeInstancesRequest();
for (Instance ins : client.getAcsResponse(dur).getInstances()) {
System.out.println(ins.getInstanceName() + "\t:" + ins.getRegionId());
}
// dur.setZoneId(zoneId);;
}
Aggregations