From c1ba5a7670d57c31ffbfa5fdc7ec9e0b6e3e5360 Mon Sep 17 00:00:00 2001 From: Mohammed Ibrahim Date: Fri, 26 Jan 2024 20:26:40 -0500 Subject: [PATCH] Hosted Service refactor (#2583) * Check string length before substring * Move generation to logic to pure * fix dependencies * fix dependencies * fix dependencies * Add validation for hostedService * add validations for hosted service * Add version to Activator Artifact * refactor sandbox deploy code * fix checkstyle * more refactor * fix checkstyle * fix checkstyle * add logs * cleanup files --- .../api/BigQueryFunctionService.java | 6 +- .../deployment/BigQueryFunctionGenerator.java | 7 +- .../deployment/BigQueryFunctionArtifact.java | 4 +- .../deployment/FunctionActivatorArtifact.java | 13 ++ .../api/HostedServiceService.java | 8 +- .../pom.xml | 8 ++ .../HostedServiceDeploymentManager.java | 128 +++++++++++------- .../deployment/HostedServiceArtifact.java | 12 +- .../deployment/HostedServiceContent.java | 8 +- .../HostedServiceDeploymentConfiguration.java | 5 +- .../HostedServiceDeploymentResult.java | 1 + .../deployment/HostedServiceDestination.java | 20 +++ .../generator/SnowflakeAppGenerator.java | 4 +- .../deployment/SnowflakeAppArtifact.java | 11 +- .../deployment/SnowflakeAppContent.java | 18 +-- 15 files changed, 159 insertions(+), 94 deletions(-) create mode 100644 legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDestination.java diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/api/BigQueryFunctionService.java b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/api/BigQueryFunctionService.java index 2d703545042..a2114bc6975 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/api/BigQueryFunctionService.java +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/api/BigQueryFunctionService.java @@ -64,14 +64,14 @@ public boolean supports(Root_meta_external_function_activator_FunctionActivator @Override public MutableList validate(Identity identity, PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, PureModelContext inputModel, Function> routerExtensions) { - BigQueryFunctionArtifact artifact = BigQueryFunctionGenerator.generateArtifact(pureModel, activator, routerExtensions); + BigQueryFunctionArtifact artifact = BigQueryFunctionGenerator.generateArtifact(pureModel, activator, inputModel, routerExtensions); return this.validateArtifact(artifact); } @Override public BigQueryFunctionDeploymentResult publishToSandbox(Identity identity, PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, PureModelContext inputModel, List runtimeConfigurations, Function> routerExtensions) { - BigQueryFunctionArtifact artifact = BigQueryFunctionGenerator.generateArtifact(pureModel, activator, routerExtensions); + BigQueryFunctionArtifact artifact = BigQueryFunctionGenerator.generateArtifact(pureModel, activator, inputModel, routerExtensions); MutableList validationErrors = this.validateArtifact(artifact); Root_meta_external_function_activator_bigQueryFunction_BigQueryFunctionDeploymentConfiguration deploymentConfiguration = ((Root_meta_external_function_activator_bigQueryFunction_BigQueryFunctionDeploymentConfiguration) activator._activationConfiguration()); @@ -83,7 +83,7 @@ public BigQueryFunctionDeploymentResult publishToSandbox(Identity identity, Pure @Override public BigQueryFunctionArtifact renderArtifact(PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, PureModelContext inputModel, String clientVersion, Function> routerExtensions) { - return BigQueryFunctionGenerator.generateArtifact(pureModel, activator, routerExtensions); + return BigQueryFunctionGenerator.generateArtifact(pureModel, activator, inputModel, routerExtensions); } @Override diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/deployment/BigQueryFunctionGenerator.java b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/deployment/BigQueryFunctionGenerator.java index aecad31fe04..4f94cbbe59d 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/deployment/BigQueryFunctionGenerator.java +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/src/main/java/org/finos/legend/engine/language/bigqueryFunction/deployment/BigQueryFunctionGenerator.java @@ -23,18 +23,21 @@ import org.finos.legend.engine.plan.generation.PlanGenerator; import org.finos.legend.engine.plan.platform.PlanPlatform; import org.finos.legend.engine.protocol.bigqueryFunction.deployment.BigQueryFunctionArtifact; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; +import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext; +import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.pure.generated.*; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.FunctionDefinition; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.PackageableFunction; public class BigQueryFunctionGenerator { - public static BigQueryFunctionArtifact generateArtifact(PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, Function> routerExtensions) + public static BigQueryFunctionArtifact generateArtifact(PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, PureModelContext inputModel, Function> routerExtensions) { Pair> artifactDetails = extractArtifactDetails(pureModel, activator, routerExtensions); Root_meta_pure_alloy_connections_alloy_specification_BigQueryDatasourceSpecification bigQueryDatasourceSpecification = artifactDetails.getOne(); RichIterable sqlExpressions = artifactDetails.getTwo(); - return new BigQueryFunctionArtifact(activator._functionName(), Lists.mutable.withAll(sqlExpressions), bigQueryDatasourceSpecification._projectId(), bigQueryDatasourceSpecification._defaultDataset()); + return new BigQueryFunctionArtifact(activator._functionName(), Lists.mutable.withAll(sqlExpressions), bigQueryDatasourceSpecification._projectId(), bigQueryDatasourceSpecification._defaultDataset(), (AlloySDLC) ((PureModelContextData)inputModel).origin.sdlcInfo); } private static Pair> extractArtifactDetails(PureModel pureModel, Root_meta_external_function_activator_bigQueryFunction_BigQueryFunction activator, Function> routerExtensions) diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/src/main/java/org/finos/legend/engine/protocol/bigqueryFunction/deployment/BigQueryFunctionArtifact.java b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/src/main/java/org/finos/legend/engine/protocol/bigqueryFunction/deployment/BigQueryFunctionArtifact.java index 236d48af71d..2bb6479acbb 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/src/main/java/org/finos/legend/engine/protocol/bigqueryFunction/deployment/BigQueryFunctionArtifact.java +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/src/main/java/org/finos/legend/engine/protocol/bigqueryFunction/deployment/BigQueryFunctionArtifact.java @@ -16,16 +16,18 @@ import org.eclipse.collections.api.list.MutableList; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; public class BigQueryFunctionArtifact extends FunctionActivatorArtifact { public String sourceProjectId; public String sourceDefaultDataset; - public BigQueryFunctionArtifact(String name, MutableList sqlExpressions, String sourceProjectId, String sourceDefaultDataset) + public BigQueryFunctionArtifact(String name, MutableList sqlExpressions, String sourceProjectId, String sourceDefaultDataset, AlloySDLC sdlc) { this.content = new BigQueryFunctionContent(name, sqlExpressions); this.sourceProjectId = sourceProjectId; this.sourceDefaultDataset = sourceDefaultDataset; + this.version = getVersionInfo(sdlc); } } diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java index e811e5ee046..c0fe6165d2a 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type") @JsonIgnoreProperties(ignoreUnknown = true) @@ -23,5 +24,17 @@ public class FunctionActivatorArtifact { public FunctionActivatorDeploymentContent content; public FunctionActivatorDeploymentConfiguration deploymentConfiguration; + + public String version; public String deployedLocation; + + + public String getVersionInfo(AlloySDLC sdlc) + { + if (this.version != null) + { + return sdlc.groupId + ":" + sdlc.artifactId + ":" + sdlc.version; + } + return ""; + } } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java index b6ed4f1372e..809a1cf36cf 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java @@ -31,6 +31,7 @@ import org.finos.legend.engine.language.hostedService.generation.HostedServiceArtifactGenerator; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.protocol.hostedService.metamodel.HostedServiceProtocolExtension; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.shared.core.identity.Identity; @@ -90,7 +91,7 @@ public MutableList validate(Identity identity, @Override public HostedServiceArtifact renderArtifact(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion, Function> routerExtensions) { - return new HostedServiceArtifact(this.hostedServiceArtifactgenerator.renderArtifact(pureModel,activator,inputModel,clientVersion,routerExtensions)); + return new HostedServiceArtifact(activator._pattern(), this.hostedServiceArtifactgenerator.renderArtifact(pureModel,activator,inputModel,clientVersion,routerExtensions), null); } @Override @@ -99,14 +100,12 @@ public List selectConfig(List e instanceof HostedServiceDeploymentConfiguration).collect(e -> (HostedServiceDeploymentConfiguration)e); } - @Override public HostedServiceDeploymentResult publishToSandbox(Identity identity, PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, List runtimeConfigs, Function> routerExtensions) { GenerationInfoData generation = this.hostedServiceArtifactgenerator.renderArtifact(pureModel, activator, inputModel, "vX_X_X",routerExtensions); - HostedServiceArtifact artifact = new HostedServiceArtifact(generation, fetchHostedService(activator, (PureModelContextData)inputModel, pureModel)); + HostedServiceArtifact artifact = new HostedServiceArtifact(activator._pattern(), generation, fetchHostedService(activator, (PureModelContextData)inputModel, pureModel), (AlloySDLC) ((PureModelContextData)inputModel).origin.sdlcInfo); return this.hostedServiceDeploymentManager.deploy(identity, artifact, runtimeConfigs); -// return new HostedServiceDeploymentResult(); } public static PureModelContextData fetchHostedService(Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContextData data, PureModel pureModel) @@ -126,5 +125,4 @@ private static String fullName(org.finos.legend.engine.protocol.pure.v1.model.pa return e._package + "::" + e.name; } - } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml index e708af0060f..2a877093310 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml @@ -94,6 +94,14 @@ + + org.apache.httpcomponents + httpclient + + + org.apache.httpcomponents + httpcore + org.eclipse.collections diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceDeploymentManager.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceDeploymentManager.java index 2d95cb87283..46dca139eb7 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceDeploymentManager.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceDeploymentManager.java @@ -15,18 +15,33 @@ package org.finos.legend.engine.language.hostedService.generation.deployment; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.util.EntityUtils; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; import org.finos.legend.engine.functionActivator.deployment.DeploymentManager; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; -import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceArtifact; -import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceDeploymentConfiguration; -import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceDeploymentResult; +import org.finos.legend.engine.protocol.hostedService.deployment.*; import org.finos.legend.engine.shared.core.ObjectMapperFactory; import org.finos.legend.engine.shared.core.identity.Identity; +import org.finos.legend.engine.shared.core.identity.credential.LegendKerberosCredential; +import org.finos.legend.engine.shared.core.kerberos.HttpClientBuilder; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.security.auth.Subject; +import java.security.PrivilegedExceptionAction; import java.util.List; public class HostedServiceDeploymentManager implements DeploymentManager { + private static final Logger LOGGER = LoggerFactory.getLogger(HostedServiceDeploymentManager.class); public static ObjectMapper mapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports(); @@ -37,61 +52,70 @@ public boolean canDeploy(FunctionActivatorArtifact element) public HostedServiceDeploymentResult deploy(Identity identity, HostedServiceArtifact artifact) { - return new HostedServiceDeploymentResult(); + return doDeploy(identity, (HostedServiceDeploymentConfiguration) artifact.deploymentConfiguration, artifact); } - public HostedServiceDeploymentResult deploy(Identity identity, HostedServiceArtifact artifact, List availableRuntimeConfigurations) { - String host; - String path; - int port; + HostedServiceDeploymentConfiguration deployConf; + MutableList c = Lists.mutable.withAll(availableRuntimeConfigurations); + if (artifact.deploymentConfiguration == null + && c.select(conf -> conf.destination.equals(((HostedServiceDeploymentConfiguration) (artifact.deploymentConfiguration)).destination)).size() > 0) + { + deployConf = c.getFirst(); + } + else + { + deployConf = (HostedServiceDeploymentConfiguration) artifact.deploymentConfiguration; + } -// if (artifact.deploymentConfiguration == null || activator._activationConfiguration()._stage()._name().equals(DeploymentStage.SANDBOX.name())) -// { -// if (availableRuntimeConfigurations.size() > 0) -// { -// host = availableRuntimeConfigurations.get(0).host; -// path = availableRuntimeConfigurations.get(0).path; -// port = availableRuntimeConfigurations.get(0).port; -// } -// else -// { -// throw new EngineException("No available configuration for sandbox deployment"); -// } -// try -// { -// HttpPost request = new HttpPost(new URIBuilder() -// .setScheme("http") -// .setHost(host) -// .setPort(port) -// .setPath(path) -// .build()); -// StringEntity stringEntity = new StringEntity(mapper.writeValueAsString(artifact)); -// stringEntity.setContentType("application/json"); -// request.setEntity(stringEntity); -// CloseableHttpClient httpclient = (CloseableHttpClient) HttpClientBuilder.getHttpClient(new BasicCookieStore()); -// Subject s = ProfileManagerHelper.extractSubject(profiles); -// Subject.doAs(s, (PrivilegedExceptionAction) () -> -// { -// HttpResponse response = httpclient.execute(request); -// return new HostedServiceDeploymentResult(); -// }); -// } -// catch (Exception e) -// { -// throw new EngineException("No available configuration for sandbox deployment"); -// -// } -// } -// else if (activator._activationConfiguration() != null) -// { -// host = ((Root_meta_external_function_activator_hostedService_HostedServiceDeploymentConfiguration)activator._activationConfiguration())._; -// path = availableRuntimeConfigurations.get(0).path; -// port = availableRuntimeConfigurations.get(0).port; -// } - return new HostedServiceDeploymentResult(); + return doDeploy(identity, deployConf, artifact); } + public HostedServiceDeploymentResult doDeploy(Identity identity, HostedServiceDeploymentConfiguration deployConf, HostedServiceArtifact artifact) + { + HostedServiceDeploymentResult result = new HostedServiceDeploymentResult(); + try + { + HttpPost request = new HttpPost(new URIBuilder() + .setScheme("https") + .setHost(deployConf.domain) + .setPort(deployConf.port) + .setPath(deployConf.path) + .build()); + StringEntity stringEntity = new StringEntity(mapper.writeValueAsString(artifact)); + stringEntity.setContentType("application/json"); + request.setEntity(stringEntity); + CloseableHttpClient httpclient = (CloseableHttpClient) HttpClientBuilder.getHttpClient(new BasicCookieStore()); + Subject subject = identity.getCredential(LegendKerberosCredential.class).get().getSubject(); + Subject.doAs(subject, (PrivilegedExceptionAction) () -> + { + HttpResponse response = httpclient.execute(request); + if (response.getStatusLine().getStatusCode() != 200) + { + result.error = EntityUtils.toString(response.getEntity()); + } + else + { + result.successful = true; + result.deploymentLocation = buildDeployStub(deployConf, artifact); + } + return "done"; + }); + //LOGGER.info("Done deploying hosted service"); + } + catch (Exception e) + { + LOGGER.error("Error deploying hosted service", e); + throw new EngineException(e.getMessage()); + } + return result; + } + + public String buildDeployStub(HostedServiceDeploymentConfiguration config, HostedServiceArtifact artifact) + { + //change to UI + return "http://" + config.domain + ":" + config.port + config.path + ((HostedServiceContent)artifact.content).pattern; + } } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java index 6d02619b4f6..adcc51d18b9 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java @@ -14,9 +14,9 @@ package org.finos.legend.engine.protocol.hostedService.deployment; -//import org.finos.legend.engine.functionActivator.deployment.FunctionActivatorArtifact; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; import org.finos.legend.engine.protocol.hostedService.deployment.model.GenerationInfo; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; public class HostedServiceArtifact extends FunctionActivatorArtifact @@ -27,14 +27,16 @@ public HostedServiceArtifact() } - public HostedServiceArtifact(GenerationInfo info) + public HostedServiceArtifact(String pattern, GenerationInfo info, AlloySDLC sdlc) { - this.content = new HostedServiceContent(info); + this.content = new HostedServiceContent(pattern, info); + this.version = getVersionInfo(sdlc); } - public HostedServiceArtifact(GenerationInfo info, PureModelContextData serviceData) + public HostedServiceArtifact(String pattern, GenerationInfo info, PureModelContextData serviceData, AlloySDLC sdlc) { - this.content = new HostedServiceContent(info, serviceData); + this.content = new HostedServiceContent(pattern, info, serviceData); + this.version = getVersionInfo(sdlc); } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceContent.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceContent.java index 6a753ecef9c..de1dc555cdf 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceContent.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceContent.java @@ -20,18 +20,20 @@ public class HostedServiceContent extends FunctionActivatorDeploymentContent { + public String pattern; public GenerationInfo info; public PureModelContextData serviceData; - public HostedServiceContent(GenerationInfo info) + public HostedServiceContent(String pattern, GenerationInfo info) { + this.pattern = pattern; this.info = info; } - public HostedServiceContent(GenerationInfo info, PureModelContextData serviceData) + public HostedServiceContent(String pattern, GenerationInfo info, PureModelContextData serviceData) { - this.info = info; + this(pattern, info); this.serviceData = serviceData; } } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentConfiguration.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentConfiguration.java index 91f156d3408..6baa41b872f 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentConfiguration.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentConfiguration.java @@ -18,5 +18,8 @@ public class HostedServiceDeploymentConfiguration extends FunctionActivatorDeploymentConfiguration { - + public HostedServiceDestination destination; + public String domain; + public int port; + public String path; } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java index 3ab1600de5e..9c94a65d782 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java @@ -18,4 +18,5 @@ public class HostedServiceDeploymentResult extends DeploymentResult { + public String error; } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDestination.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDestination.java new file mode 100644 index 00000000000..df333702ddc --- /dev/null +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDestination.java @@ -0,0 +1,20 @@ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.finos.legend.engine.protocol.hostedService.deployment; + +public enum HostedServiceDestination +{ + Sandbox, + Production +} diff --git a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/src/main/java/org/finos/legend/engine/language/snowflakeApp/generator/SnowflakeAppGenerator.java b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/src/main/java/org/finos/legend/engine/language/snowflakeApp/generator/SnowflakeAppGenerator.java index ec1687597bb..34e9de9d2e2 100644 --- a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/src/main/java/org/finos/legend/engine/language/snowflakeApp/generator/SnowflakeAppGenerator.java +++ b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/src/main/java/org/finos/legend/engine/language/snowflakeApp/generator/SnowflakeAppGenerator.java @@ -69,10 +69,10 @@ public static SnowflakeAppArtifact generateArtifact(PureModel pureModel, Root_me .select(c -> c.getPath().equals(((org.finos.legend.engine.protocol.snowflakeApp.metamodel.SnowflakeAppDeploymentConfiguration)protocolActivator.activationConfiguration).activationConnection.connection)).getFirst().connectionValue; SnowflakeDatasourceSpecification ds = (SnowflakeDatasourceSpecification)connection.datasourceSpecification; String deployedLocation = String.format("https://app.%s.privatelink.snowflakecomputing.com/%s/%s/data/databases/%S", ds.region, ds.region, ds.accountName, ds.databaseName); - return new SnowflakeAppArtifact(content, new SnowflakeAppDeploymentConfiguration(connection), deployedLocation); + return new SnowflakeAppArtifact(content, new SnowflakeAppDeploymentConfiguration(connection), deployedLocation, sdlc); } - return new SnowflakeAppArtifact(content); + return new SnowflakeAppArtifact(content, sdlc); } private static RichIterable extractSQLExpressions(Root_meta_pure_executionPlan_ExecutionPlan executionPlan) diff --git a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppArtifact.java b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppArtifact.java index 21281c83514..2fdf05feb3a 100644 --- a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppArtifact.java +++ b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppArtifact.java @@ -15,6 +15,7 @@ package org.finos.legend.engine.protocol.snowflakeApp.deployment; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; public class SnowflakeAppArtifact extends FunctionActivatorArtifact { @@ -24,14 +25,18 @@ public SnowflakeAppArtifact() //empty artifact } - public SnowflakeAppArtifact(SnowflakeAppContent content) + public SnowflakeAppArtifact(SnowflakeAppContent content, AlloySDLC sdlc) { this.content = content; + if (sdlc != null) + { + this.version = getVersionInfo(sdlc); + } } - public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation) + public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation, AlloySDLC sdlc) { - this(content); + this(content, sdlc); this.deploymentConfiguration = config; this.deployedLocation = deployedLocation; } diff --git a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppContent.java b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppContent.java index 35ef6ff4ad7..fe8e60b91d3 100644 --- a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppContent.java +++ b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-protocol/src/main/java/org/finos/legend/engine/protocol/snowflakeApp/deployment/SnowflakeAppContent.java @@ -30,9 +30,6 @@ public class SnowflakeAppContent extends FunctionActivatorDeploymentContent public String applicationName; public String description; public List owners; - public String groupId; - public String artifactId; - public String version; public String creationTime; public SnowflakeAppContent() @@ -46,12 +43,7 @@ public SnowflakeAppContent(String applicationName, MutableList sqlExpres this.sqlExpressions = sqlExpressions; this.creationTime = convertToValidDate(new Date()); this.functionArguments = functionArguments; - if (sdlc != null) - { - this.groupId = sdlc.groupId; - this.artifactId = sdlc.artifactId; - this.version = sdlc.version; - } + } public SnowflakeAppContent(String applicationName, MutableList sqlExpressions, String description, String functionArguments, List owners, AlloySDLC sdlc) @@ -68,13 +60,5 @@ public static String convertToValidDate(Date date) return format.format(date); } - public String getVersionInfo() - { - if (this.version != null) - { - return groupId + ":" + this.artifactId + ":" + this.version; - } - return ""; - } }