Search in sources :

Example 1 with CounterResponse

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);
}
Also used : Counter(com.cloud.network.as.Counter) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

Example 2 with CounterResponse

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());
    }
}
Also used : Counter(com.cloud.network.as.Counter) ServerApiException(org.apache.cloudstack.api.ServerApiException) CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

Example 3 with CounterResponse

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;
}
Also used : ConditionResponse(org.apache.cloudstack.api.response.ConditionResponse) ArrayList(java.util.ArrayList) CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

Example 4 with CounterResponse

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;
}
Also used : CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

Aggregations

CounterResponse (org.apache.cloudstack.api.response.CounterResponse)4 Counter (com.cloud.network.as.Counter)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ConditionResponse (org.apache.cloudstack.api.response.ConditionResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1