Search in sources :

Example 1 with ConfigurationVo

use of org.ligoj.app.api.ConfigurationVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method getConfiguration.

@Test
public void getConfiguration() throws Exception {
    final int subscription = repository.findByExpected("node.id", "service:vm:vcloud:sample").getId();
    final ConfigurationVo configuration = resource.getConfiguration(subscription);
    // Not secured parameter
    Assertions.assertEquals("http://localhost:8120", configuration.getParameters().get("service:vm:vcloud:url"));
    // Secured parameter
    Assertions.assertNull(configuration.getParameters().get("service:vm:vcloud:user"));
    Assertions.assertEquals(subscription, configuration.getSubscription());
    Assertions.assertEquals("gStack", configuration.getProject().getName());
    Assertions.assertEquals("service:vm:vcloud:sample", configuration.getNode().getId());
    Assertions.assertNotNull(configuration.getConfiguration());
}
Also used : ConfigurationVo(org.ligoj.app.api.ConfigurationVo) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 2 with ConfigurationVo

use of org.ligoj.app.api.ConfigurationVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method getConfigurationNone.

@Test
public void getConfigurationNone() throws Exception {
    final int subscription = repository.findByExpected("node.id", "service:km:confluence:dig").getId();
    final ConfigurationVo configuration = resource.getConfiguration(subscription);
    Assertions.assertEquals(subscription, configuration.getSubscription());
    Assertions.assertEquals("gStack", configuration.getProject().getName());
    Assertions.assertEquals("service:km:confluence:dig", configuration.getNode().getId());
    // No configuration for Confluence
    Assertions.assertNull(configuration.getConfiguration());
}
Also used : ConfigurationVo(org.ligoj.app.api.ConfigurationVo) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 3 with ConfigurationVo

use of org.ligoj.app.api.ConfigurationVo in project ligoj-api by ligoj.

the class SubscriptionResource method getConfiguration.

/**
 * Return tools specific configuration. Only non secured parameters are returned.
 *
 * @param id
 *            The subscription identifier.
 * @return tools specific configuration.
 * @throws Exception
 *             When the configuration gathering fails. Managed at JAX-RS level.
 */
@GET
@Path("{id:\\d+}/configuration")
@org.springframework.transaction.annotation.Transactional(readOnly = true)
public ConfigurationVo getConfiguration(@PathParam("id") final int id) throws Exception {
    // Copy subscription details
    final Subscription entity = checkVisibleSubscription(id);
    final ConfigurationVo vo = new ConfigurationVo();
    vo.setNode(NodeResource.toVo(entity.getNode()));
    vo.setParameters(getNonSecuredParameters(id));
    vo.setSubscription(id);
    vo.setProject(DescribedBean.clone(entity.getProject()));
    // Get specific configuration
    final ConfigurablePlugin servicePlugin = locator.getResource(vo.getNode().getId(), ConfigurablePlugin.class);
    if (servicePlugin != null) {
        // Specific configuration is available
        vo.setConfiguration(servicePlugin.getConfiguration(id));
    }
    return vo;
}
Also used : ConfigurablePlugin(org.ligoj.app.api.ConfigurablePlugin) ConfigurationVo(org.ligoj.app.api.ConfigurationVo) Subscription(org.ligoj.app.model.Subscription) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ConfigurationVo (org.ligoj.app.api.ConfigurationVo)3 Test (org.junit.jupiter.api.Test)2 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 ConfigurablePlugin (org.ligoj.app.api.ConfigurablePlugin)1 Subscription (org.ligoj.app.model.Subscription)1