Search in sources :

Example 6 with APIIntegration

use of io.syndesis.server.api.generator.APIIntegration in project syndesis by syndesisio.

the class ApiGeneratorHelper method generateIntegrationUpdateFrom.

public static APIIntegration generateIntegrationUpdateFrom(final Integration existing, final APIFormData apiFormData, final DataManager dataManager, final APIGenerator apiGenerator) {
    final APIIntegration newApiIntegration = generateIntegrationFrom(apiFormData, dataManager, apiGenerator);
    final Integration newIntegration = newApiIntegration.getIntegration();
    final Integration updatedIntegration = newIntegration.builder().id(existing.getId()).build();
    return new APIIntegration(updatedIntegration, newApiIntegration.getSpec());
}
Also used : APIIntegration(io.syndesis.server.api.generator.APIIntegration) Integration(io.syndesis.common.model.integration.Integration) APIIntegration(io.syndesis.server.api.generator.APIIntegration)

Example 7 with APIIntegration

use of io.syndesis.server.api.generator.APIIntegration in project syndesis by syndesisio.

the class ApiHandler method updateIntegrationFromSpecification.

@PUT
@Path("/generator")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Operation(description = "Update the provided integration from a API specification. Does not store it in the database")
public Response updateIntegrationFromSpecification(@MultipartForm final APIUpdateFormData apiUpdateFormData) {
    final DataManager dataManager = getDataManager();
    final Integration existing = apiUpdateFormData.integration;
    final APIIntegration apiIntegration = ApiGeneratorHelper.generateIntegrationUpdateFrom(existing, apiUpdateFormData, dataManager, apiGenerator);
    final Integration givenIntegration = apiIntegration.getIntegration();
    final Integration updated = ApiGeneratorHelper.updateFlowsAndStartAndEndDataShapes(existing, givenIntegration);
    final OpenApi existingApiSpecification = ApiGeneratorHelper.specificationFrom(resourceManager, existing).orElse(null);
    if (Objects.equals(existing.getFlows(), updated.getFlows()) && Objects.equals(existingApiSpecification, apiIntegration.getSpec())) {
        // no changes were made to the flows or to the specification
        return Response.notModified().build();
    }
    // store the OpenAPI resource, we keep the old one as it might
    // be referenced from Integration's stored in IntegrationDeployent's
    // this gives us a rollback mechanism
    final OpenApi openApi = apiIntegration.getSpec();
    dataManager.store(openApi, OpenApi.class);
    return Response.accepted(updated).build();
}
Also used : APIIntegration(io.syndesis.server.api.generator.APIIntegration) Integration(io.syndesis.common.model.integration.Integration) DataManager(io.syndesis.server.dao.manager.DataManager) APIIntegration(io.syndesis.server.api.generator.APIIntegration) OpenApi(io.syndesis.common.model.openapi.OpenApi) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) Operation(io.swagger.v3.oas.annotations.Operation) PUT(javax.ws.rs.PUT)

Aggregations

APIIntegration (io.syndesis.server.api.generator.APIIntegration)7 Integration (io.syndesis.common.model.integration.Integration)6 OpenApi (io.syndesis.common.model.openapi.OpenApi)5 Flow (io.syndesis.common.model.integration.Flow)4 ProvidedApiTemplate (io.syndesis.server.api.generator.ProvidedApiTemplate)4 Kind (io.syndesis.common.model.Kind)3 ResourceIdentifier (io.syndesis.common.model.ResourceIdentifier)3 Step (io.syndesis.common.model.integration.Step)3 APIGenerator (io.syndesis.server.api.generator.APIGenerator)3 DataManager (io.syndesis.server.dao.manager.DataManager)3 StandardCharsets (java.nio.charset.StandardCharsets)3 Optional (java.util.Optional)3 Operation (io.swagger.v3.oas.annotations.Operation)2 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)2 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)2 Connection (io.syndesis.common.model.connection.Connection)2 Connector (io.syndesis.common.model.connection.Connector)2 IntegrationResourceManager (io.syndesis.integration.api.IntegrationResourceManager)2 EncryptionComponent (io.syndesis.server.dao.manager.EncryptionComponent)2 APIFormData (io.syndesis.server.endpoint.v1.handler.api.ApiHandler.APIFormData)2