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