use of org.alien4cloud.tosca.model.templates.Topology in project alien4cloud by alien4cloud.
the class TopologyController method get.
/**
* Retrieve an existing {@link Topology}
*
* @param topologyId The id of the topology to retrieve.
* @return {@link RestResponse}<{@link TopologyDTO}> containing the {@link Topology} and the {@link NodeType} related
* to his {@link NodeTemplate}s
*/
@ApiOperation(value = "Retrieve a topology from it's id.", notes = "Returns a topology with it's details. Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ]")
@RequestMapping(value = "/{topologyId:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> get(@PathVariable String topologyId) {
Topology topology = topologyServiceCore.getOrFail(topologyId);
topologyService.checkAccessAuthorizations(topology);
try {
topologyEditionContextManager.init(topologyId);
editorService.checkTopologyRecovery();
return RestResponseBuilder.<TopologyDTO>builder().data(dtoBuilder.buildTopologyDTO(EditionContextManager.get())).build();
} finally {
topologyEditionContextManager.destroy();
}
}
use of org.alien4cloud.tosca.model.templates.Topology in project alien4cloud by alien4cloud.
the class TopologyController method isTopologyValid.
/**
* Check if a topology is valid or not.
*
* @param topologyId The id of the topology to check.
* @return a boolean rest response that says if the topology is valid or not.
*/
@ApiOperation(value = "Check if a topology is valid or not.", notes = "Returns true if valid, false if not. Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ]")
@RequestMapping(value = "/{topologyId:.+}/isvalid", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyValidationResult> isTopologyValid(@PathVariable String topologyId, @RequestParam(required = false) String environmentId) {
Topology topology = topologyServiceCore.getOrFail(topologyId);
topologyService.checkAccessAuthorizations(topology);
TopologyValidationResult dto = topologyValidationService.validateTopology(topology);
return RestResponseBuilder.<TopologyValidationResult>builder().data(dto).build();
}
use of org.alien4cloud.tosca.model.templates.Topology in project alien4cloud by alien4cloud.
the class TopologyTemplateStepDefinitions method i_Should_Be_Able_To_Retrieve_A_Topology_With_Name_Version_And_Store_It_As_A_SPEL_Context.
@And("^I should be able to retrieve a topology with name \"([^\"]*)\" version \"([^\"]*)\" and store it as a SPEL context$")
public void i_Should_Be_Able_To_Retrieve_A_Topology_With_Name_Version_And_Store_It_As_A_SPEL_Context(String name, String version) throws Throwable {
String topologyId = TestUtils.getFullId(name, version);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().get("/rest/v1/catalog/topologies/" + topologyId));
commonStepDefinitions.I_should_receive_a_RestResponse_with_no_error();
// register the retrieved topology as SPEL context
Topology topology = JsonUtil.read(Context.getInstance().getRestResponse(), Topology.class, Context.getJsonMapper()).getData();
Context.getInstance().registerTopologyId(topologyId);
Context.getInstance().buildEvaluationContext(topology);
}
use of org.alien4cloud.tosca.model.templates.Topology in project alien4cloud by alien4cloud.
the class TopologyTemplateStepDefinitions method i_Should_Be_Able_To_Retrieve_A_Topology_With_Name_And_Store_It_As_A_SPEL_Context.
@And("^I should be able to retrieve a topology with name \"([^\"]*)\" and store it as a SPEL context$")
public void i_Should_Be_Able_To_Retrieve_A_Topology_With_Name_And_Store_It_As_A_SPEL_Context(String name) throws Throwable {
CatalogVersionResult version = getOneTopologyVersion(name);
assertNotNull(version);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().get("/rest/v1/catalog/topologies/" + version.getId()));
commonStepDefinitions.I_should_receive_a_RestResponse_with_no_error();
// register the retrieved topology as SPEL context
Topology topology = JsonUtil.read(Context.getInstance().getRestResponse(), Topology.class, Context.getJsonMapper()).getData();
Context.getInstance().registerTopologyId(topology.getId());
Context.getInstance().buildEvaluationContext(topology);
}
use of org.alien4cloud.tosca.model.templates.Topology in project alien4cloud by alien4cloud.
the class TopologyTemplateStepDefinitions method getTopologyTemplateIdFromName.
public static String getTopologyTemplateIdFromName(String topologyTemplateName) throws Throwable {
// first search from the context
String topologyId = Context.getInstance().getTopologyTemplateId(topologyTemplateName, null);
if (StringUtils.isNotBlank(topologyId)) {
return topologyId;
}
// if not found, then search from the repo
Topology topology = getTopologyFromName(topologyTemplateName);
return topology.getId();
}
Aggregations