use of com.cloud.api.response.RegionResponse in project cosmic by MissionCriticalCloud.
the class ListRegionsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final List<? extends Region> result = _regionService.listRegions(this);
final ListResponse<RegionResponse> response = new ListResponse<>();
final List<RegionResponse> regionResponses = new ArrayList<>();
for (final Region region : result) {
final RegionResponse regionResponse = _responseGenerator.createRegionResponse(region);
regionResponse.setObjectName("region");
regionResponses.add(regionResponse);
}
response.setResponses(regionResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.RegionResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createRegionResponse.
@Override
public RegionResponse createRegionResponse(final Region region) {
final RegionResponse response = new RegionResponse();
response.setId(region.getId());
response.setName(region.getName());
response.setEndPoint(region.getEndPoint());
response.setObjectName("region");
return response;
}
use of com.cloud.api.response.RegionResponse in project cosmic by MissionCriticalCloud.
the class RegionCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
final RegionService regionService = Mockito.mock(RegionService.class);
final Region region = Mockito.mock(Region.class);
Mockito.when(regionService.addRegion(Matchers.anyInt(), Matchers.anyString(), Matchers.anyString())).thenReturn(region);
addRegionCmd._regionService = regionService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
final RegionResponse regionResponse = Mockito.mock(RegionResponse.class);
Mockito.when(responseGenerator.createRegionResponse(region)).thenReturn(regionResponse);
addRegionCmd._responseGenerator = responseGenerator;
addRegionCmd.execute();
}
use of com.cloud.api.response.RegionResponse in project cosmic by MissionCriticalCloud.
the class AddRegionCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Region region = _regionService.addRegion(getId(), getRegionName(), getEndPoint());
if (region != null) {
final RegionResponse response = _responseGenerator.createRegionResponse(region);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Region");
}
}
use of com.cloud.api.response.RegionResponse in project cosmic by MissionCriticalCloud.
the class UpdateRegionCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Region region = _regionService.updateRegion(getId(), getRegionName(), getEndPoint());
if (region != null) {
final RegionResponse response = _responseGenerator.createRegionResponse(region);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update Region");
}
}
Aggregations