Search in sources :

Example 1 with SnapshotPolicyResponse

use of org.apache.cloudstack.api.response.SnapshotPolicyResponse in project cloudstack by apache.

the class ApiResponseHelper method createSnapshotPolicyResponse.

@Override
public SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy) {
    SnapshotPolicyResponse policyResponse = new SnapshotPolicyResponse();
    policyResponse.setId(policy.getUuid());
    Volume vol = ApiDBUtils.findVolumeById(policy.getVolumeId());
    if (vol != null) {
        policyResponse.setVolumeId(vol.getUuid());
    }
    policyResponse.setSchedule(policy.getSchedule());
    policyResponse.setIntervalType(policy.getInterval());
    policyResponse.setMaxSnaps(policy.getMaxSnaps());
    policyResponse.setTimezone(policy.getTimezone());
    policyResponse.setForDisplay(policy.isDisplay());
    policyResponse.setObjectName("snapshotpolicy");
    return policyResponse;
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) Volume(com.cloud.storage.Volume)

Example 2 with SnapshotPolicyResponse

use of org.apache.cloudstack.api.response.SnapshotPolicyResponse in project cloudstack by apache.

the class CreateSnapshotPolicyCmd method execute.

@Override
public void execute() {
    SnapshotPolicy result = _snapshotService.createPolicy(this, _accountService.getAccount(getEntityOwnerId()));
    if (result != null) {
        SnapshotPolicyResponse response = _responseGenerator.createSnapshotPolicyResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot policy");
    }
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 3 with SnapshotPolicyResponse

use of org.apache.cloudstack.api.response.SnapshotPolicyResponse in project cloudstack by apache.

the class ListSnapshotPoliciesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends SnapshotPolicy>, Integer> result = _snapshotService.listPoliciesforVolume(this);
    ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
    List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
    for (SnapshotPolicy policy : result.first()) {
        SnapshotPolicyResponse policyResponse = _responseGenerator.createSnapshotPolicyResponse(policy);
        policyResponse.setObjectName("snapshotpolicy");
        policyResponses.add(policyResponse);
    }
    response.setResponses(policyResponses, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with SnapshotPolicyResponse

use of org.apache.cloudstack.api.response.SnapshotPolicyResponse in project cloudstack by apache.

the class UpdateSnapshotPolicyCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("SnapshotPolicy Id: " + getId());
    SnapshotPolicy result = _snapshotService.updateSnapshotPolicy(this);
    if (result != null) {
        SnapshotPolicyResponse response = _responseGenerator.createSnapshotPolicyResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update snapshot policy");
    }
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Aggregations

SnapshotPolicyResponse (org.apache.cloudstack.api.response.SnapshotPolicyResponse)4 SnapshotPolicy (com.cloud.storage.snapshot.SnapshotPolicy)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 Volume (com.cloud.storage.Volume)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1