use of org.apache.cloudstack.api.response.CounterResponse in project cloudstack by apache.
the class ListCountersCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
List<? extends Counter> counters = null;
counters = _autoScaleService.listCounters(this);
ListResponse<CounterResponse> response = new ListResponse<CounterResponse>();
List<CounterResponse> ctrResponses = new ArrayList<CounterResponse>();
for (Counter ctr : counters) {
CounterResponse ctrResponse = _responseGenerator.createCounterResponse(ctr);
ctrResponses.add(ctrResponse);
}
response.setResponses(ctrResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.CounterResponse in project cloudstack by apache.
the class CreateCounterCmd method create.
@Override
public void create() {
Counter ctr = null;
ctr = _autoScaleService.createCounter(this);
if (ctr != null) {
this.setEntityId(ctr.getId());
this.setEntityUuid(ctr.getUuid());
CounterResponse response = _responseGenerator.createCounterResponse(ctr);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
}
}
use of org.apache.cloudstack.api.response.CounterResponse 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;
}
use of org.apache.cloudstack.api.response.CounterResponse in project cloudstack by apache.
the class ApiResponseHelper method createCounterResponse.
@Override
public CounterResponse createCounterResponse(Counter counter) {
CounterResponse response = new CounterResponse();
response.setId(counter.getUuid());
response.setSource(counter.getSource().toString());
response.setName(counter.getName());
response.setValue(counter.getValue());
response.setObjectName("counter");
return response;
}
Aggregations