Search in sources :

Example 1 with LocationDTO

use of alien4cloud.rest.orchestrator.model.LocationDTO in project alien4cloud by alien4cloud.

the class LocationController method buildLocationDTO.

private LocationDTO buildLocationDTO(Location location) {
    LocationDTO locationDTO = new LocationDTO();
    locationDTO.setResources(locationResourceService.getLocationResources(location));
    locationDTO.setLocation(location);
    locationDTO.setSecretProviderConfigurations(getSecretConfigurations(location));
    return locationDTO;
}
Also used : LocationDTO(alien4cloud.rest.orchestrator.model.LocationDTO)

Example 2 with LocationDTO

use of alien4cloud.rest.orchestrator.model.LocationDTO in project alien4cloud by alien4cloud.

the class LocationController method getAll.

@ApiOperation(value = "Get all locations for a given orchestrator.")
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<List<LocationDTO>> getAll(@ApiParam(value = "Id of the orchestrator for which to get all locations.") @PathVariable String orchestratorId) {
    List<Location> locations = locationService.getAll(orchestratorId);
    List<LocationDTO> locationDTOs = Lists.newArrayList();
    for (Location location : locations) {
        locationDTOs.add(buildLocationDTO(location));
    }
    return RestResponseBuilder.<List<LocationDTO>>builder().data(locationDTOs).build();
}
Also used : List(java.util.List) LocationDTO(alien4cloud.rest.orchestrator.model.LocationDTO) Location(alien4cloud.model.orchestrators.locations.Location) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with LocationDTO

use of alien4cloud.rest.orchestrator.model.LocationDTO in project alien4cloud by alien4cloud.

the class AbstractLocationResourceSteps method resourceFoundInLocation.

private boolean resourceFoundInLocation(String resourceName, String resourceType, IResourceAccessor resourceAccessor) throws IOException {
    String restResponse = Context.getInstance().getRestResponse();
    RestResponse<LocationDTO> response = JsonUtil.read(restResponse, LocationDTO.class, Context.getJsonMapper());
    LocationDTO locationDTO = response.getData();
    boolean found = false;
    final List<? extends AbstractLocationResourceTemplate> templates = resourceAccessor.getResources(locationDTO.getResources());
    for (AbstractLocationResourceTemplate lrt : templates) {
        if (lrt.getName().equals(resourceName) && lrt.getTypes().contains(resourceType)) {
            found = true;
            break;
        }
    }
    return found;
}
Also used : AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationDTO(alien4cloud.rest.orchestrator.model.LocationDTO)

Example 4 with LocationDTO

use of alien4cloud.rest.orchestrator.model.LocationDTO in project alien4cloud by alien4cloud.

the class LocationsDefinitionsSteps method Response_should_contains_meta_property_for_the_location.

@Then("^Response should contains (\\d+) meta-property for the location \"([^\"]*)\"$")
public void Response_should_contains_meta_property_for_the_location(int count, String locationName) throws Throwable {
    RestResponse<List> response = JsonUtil.read(Context.getInstance().getRestResponse(), List.class);
    assertNotNull(response);
    for (Object obj : response.getData()) {
        LocationDTO location = Context.getInstance().getJsonMapper().readValue(Context.getInstance().getJsonMapper().writeValueAsString(obj), LocationDTO.class);
        if (locationName.equals(location.getLocation().getName())) {
            currentMetaProperties = location.getLocation().getMetaProperties();
            break;
        }
    }
    Assert.assertEquals(count, currentMetaProperties.size());
}
Also used : List(java.util.List) LocationDTO(alien4cloud.rest.orchestrator.model.LocationDTO) Then(cucumber.api.java.en.Then)

Aggregations

LocationDTO (alien4cloud.rest.orchestrator.model.LocationDTO)4 List (java.util.List)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)1 Location (alien4cloud.model.orchestrators.locations.Location)1 Then (cucumber.api.java.en.Then)1 ApiOperation (io.swagger.annotations.ApiOperation)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1