Search in sources :

Example 71 with Topology

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();
    }
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Topology(org.alien4cloud.tosca.model.templates.Topology) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 72 with Topology

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();
}
Also used : TopologyValidationResult(alien4cloud.topology.TopologyValidationResult) Topology(org.alien4cloud.tosca.model.templates.Topology) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 73 with 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_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);
}
Also used : Topology(org.alien4cloud.tosca.model.templates.Topology) And(cucumber.api.java.en.And)

Example 74 with 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);
}
Also used : CatalogVersionResult(org.alien4cloud.tosca.catalog.CatalogVersionResult) Topology(org.alien4cloud.tosca.model.templates.Topology) And(cucumber.api.java.en.And)

Example 75 with 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();
}
Also used : Topology(org.alien4cloud.tosca.model.templates.Topology)

Aggregations

Topology (org.alien4cloud.tosca.model.templates.Topology)79 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)22 Map (java.util.Map)21 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)17 Csar (org.alien4cloud.tosca.model.Csar)16 Application (alien4cloud.model.application.Application)15 NotFoundException (alien4cloud.exception.NotFoundException)14 ApiOperation (io.swagger.annotations.ApiOperation)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)12 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)9 FlowExecutionContext (org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext)9 NodeType (org.alien4cloud.tosca.model.types.NodeType)9 IOException (java.io.IOException)8 List (java.util.List)8 DeploymentMatchingConfiguration (org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration)8 Component (org.springframework.stereotype.Component)8 Audit (alien4cloud.audit.annotation.Audit)7