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;
}
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");
}
}
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);
}
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");
}
}
Aggregations