Search in sources :

Example 1 with Alert

use of com.cloud.alert.Alert in project CloudStack-archive by CloudStack-extras.

the class ListAlertsCmd method execute.

@Override
public void execute() {
    List<? extends Alert> result = _mgr.searchForAlerts(this);
    ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
    List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
    for (Alert alert : result) {
        AlertResponse alertResponse = new AlertResponse();
        alertResponse.setId(alert.getId());
        alertResponse.setAlertType(alert.getType());
        alertResponse.setDescription(alert.getSubject());
        alertResponse.setLastSent(alert.getLastSent());
        alertResponse.setObjectName("alert");
        alertResponseList.add(alertResponse);
    }
    response.setResponses(alertResponseList);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) AlertResponse(com.cloud.api.response.AlertResponse) ArrayList(java.util.ArrayList) Alert(com.cloud.alert.Alert)

Example 2 with Alert

use of com.cloud.alert.Alert in project cloudstack by apache.

the class ListAlertsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends Alert>, Integer> result = _mgr.searchForAlerts(this);
    ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
    List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
    for (Alert alert : result.first()) {
        AlertResponse alertResponse = new AlertResponse();
        alertResponse.setId(alert.getUuid());
        alertResponse.setAlertType(alert.getType());
        alertResponse.setDescription(alert.getSubject());
        alertResponse.setLastSent(alert.getLastSent());
        alertResponse.setName(alert.getName());
        alertResponse.setObjectName("alert");
        alertResponseList.add(alertResponse);
    }
    response.setResponses(alertResponseList, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) AlertResponse(org.apache.cloudstack.api.response.AlertResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Alert(com.cloud.alert.Alert)

Aggregations

Alert (com.cloud.alert.Alert)2 ArrayList (java.util.ArrayList)2 AlertResponse (com.cloud.api.response.AlertResponse)1 ListResponse (com.cloud.api.response.ListResponse)1 List (java.util.List)1 AlertResponse (org.apache.cloudstack.api.response.AlertResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1