use of org.apache.cloudstack.api.response.ConditionResponse in project cloudstack by apache.
the class ApiResponseHelper method createAutoScalePolicyResponse.
@Override
public AutoScalePolicyResponse createAutoScalePolicyResponse(AutoScalePolicy policy) {
AutoScalePolicyResponse response = new AutoScalePolicyResponse();
response.setId(policy.getUuid());
response.setDuration(policy.getDuration());
response.setQuietTime(policy.getQuietTime());
response.setAction(policy.getAction());
List<ConditionVO> vos = ApiDBUtils.getAutoScalePolicyConditions(policy.getId());
ArrayList<ConditionResponse> conditions = new ArrayList<ConditionResponse>(vos.size());
for (ConditionVO vo : vos) {
conditions.add(createConditionResponse(vo));
}
response.setConditions(conditions);
response.setObjectName("autoscalepolicy");
// Populates the account information in the response
populateOwner(response, policy);
return response;
}
use of org.apache.cloudstack.api.response.ConditionResponse in project cloudstack by apache.
the class ListConditionsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
List<? extends Condition> conditions = null;
conditions = _autoScaleService.listConditions(this);
ListResponse<ConditionResponse> response = new ListResponse<ConditionResponse>();
List<ConditionResponse> cndnResponses = new ArrayList<ConditionResponse>();
for (Condition cndn : conditions) {
ConditionResponse cndnResponse = _responseGenerator.createConditionResponse(cndn);
cndnResponses.add(cndnResponse);
}
response.setResponses(cndnResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ConditionResponse in project cloudstack by apache.
the class CreateConditionCmd method execute.
@Override
public void execute() {
Condition condition = _entityMgr.findById(Condition.class, getEntityId());
ConditionResponse response = _responseGenerator.createConditionResponse(condition);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ConditionResponse in project cloudstack by apache.
the class ApiResponseHelper method createConditionResponse.
@Override
public ConditionResponse createConditionResponse(Condition condition) {
ConditionResponse response = new ConditionResponse();
response.setId(condition.getUuid());
List<CounterResponse> counterResponseList = new ArrayList<CounterResponse>();
counterResponseList.add(createCounterResponse(ApiDBUtils.getCounter(condition.getCounterid())));
response.setCounterResponse(counterResponseList);
response.setRelationalOperator(condition.getRelationalOperator().toString());
response.setThreshold(condition.getThreshold());
response.setObjectName("condition");
populateOwner(response, condition);
return response;
}
Aggregations