use of com.aliyuncs.fc_open.model.v20200310.OpenFcServiceResponse 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());
}
}
Aggregations