From 80c4bd54825bf1b8e39d31039309e4f390c10f00 Mon Sep 17 00:00:00 2001 From: janeenyamak1 Date: Tue, 3 Dec 2024 19:04:09 -0500 Subject: [PATCH] Allow snowflake app to support post deployment actions --- .../pom.xml | 4 ++++ .../generator/SnowflakeAppGenerator.java | 9 +++++++-- .../deployment/SnowflakeAppArtifact.java | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/pom.xml b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/pom.xml index a87e32b81a3..a16d05224bf 100644 --- a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/pom.xml +++ b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-generator/pom.xml @@ -136,6 +136,10 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake-pure + + org.finos.legend.engine + legend-engine-xt-functionActivator-generation + com.fasterxml.jackson.core 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 e1fac536c1c..f312c5c4a03 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 @@ -18,9 +18,11 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.block.function.Function; import org.eclipse.collections.impl.factory.Lists; +import org.finos.legend.engine.functionActivator.generation.FunctionActivatorGenerator; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.plan.generation.PlanGenerator; import org.finos.legend.engine.plan.platform.PlanPlatform; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; 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; @@ -38,6 +40,8 @@ import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.FunctionDefinition; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.PackageableFunction; +import java.util.List; + public class SnowflakeAppGenerator { @@ -55,6 +59,7 @@ public static SnowflakeAppArtifact generateArtifact(PureModel pureModel, Root_me } } SnowflakeAppContent content = new SnowflakeAppContent(activator._applicationName(), fullArtifact._createQuery(), fullArtifact._grantStatement(), activator._permissionScheme().toString(), activator._description(), ((Root_meta_external_function_activator_DeploymentOwnership)activator._ownership())._id(), Lists.mutable.withAll(fullArtifact._tables())); + List actionContents = FunctionActivatorGenerator.generateActions(activator, pureModel); if (activator._activationConfiguration() != null) { //identify connection @@ -65,9 +70,9 @@ 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, sdlc); + return new SnowflakeAppArtifact(content, new SnowflakeAppDeploymentConfiguration(connection), deployedLocation, actionContents, sdlc); } - return new SnowflakeAppArtifact(content, sdlc); + return new SnowflakeAppArtifact(content, actionContents, sdlc); } public static String generateFunctionLineage(PureModel pureModel, Root_meta_external_function_activator_snowflakeApp_SnowflakeApp activator, PureModelContext inputModel, Function> routerExtensions) 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 fec5ecebf93..324e6d1f7c7 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,8 +15,11 @@ package org.finos.legend.engine.protocol.snowflakeApp.deployment; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; +import java.util.List; + public class SnowflakeAppArtifact extends FunctionActivatorArtifact { public String deployedLocation; @@ -35,6 +38,16 @@ public SnowflakeAppArtifact(SnowflakeAppContent content, AlloySDLC sdlc) } } + public SnowflakeAppArtifact(SnowflakeAppContent content, List actions, AlloySDLC sdlc) + { + this.content = content; + this.actions = actions; + if (sdlc != null) + { + this.version = getVersionInfo(sdlc); + } + } + public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation, AlloySDLC sdlc) { this(content, sdlc); @@ -42,4 +55,11 @@ public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentC this.deployedLocation = deployedLocation; } + public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation, List actions, AlloySDLC sdlc) + { + this(content, actions, sdlc); + this.deploymentConfiguration = config; + this.deployedLocation = deployedLocation; + } + }