There are several cases in which it would be beneficial to allow users to trigger integration jobs, ad hoc, from within the Anaplan platform, but there is no native feature that allows this. Previously, I described a solution that simulates this functionality using only Anaplan Connect.
This article presents a solution that uses Python, leveraging the Flask microservice. This approach provides a highly adaptable and scalable solution, which can interact with any platform that has a scriptable interface (JDBC/ODBC connector, API, etc). Rather than scheduling a script to check for a boolean status, this allows you to add a simple link to a dashboard that, when clicked, executes the script to carry out the desired functions.
Setting up the environment
This solution requires that the following applications are installed on the client server for all use cases:
Additional Python modules may be required, depending on the specific requirements for the solution.
Setting up your virtual environment
Once you have installed VirtualEnvironment, create a directory where you wish this project to reside. From a terminal, navigate to the directory and execute the following to create a virtual environment:
This will create a subdirectory called ENV, which contains the scripts required for the virtual environment to run.
Setting up the Python script
The following section describes the essential elements required by the script. The first line imports the Flask datatype from the flask framework. The next lines creates the Flask instance and tell it which patch to listen to for incoming requests and which REST methods are allowed. The function will print “Hello, world!” to the web browser if someone navigates to the IP address server and defined path. e.g. http://192.168.0.103:5000/path The final lines start the Flask instance when the script is executed and bind the app to the specified IP address and port. In this case, it listens on all IPv4 address bound to the machine on port 5001. If these are undefined, and app.run() is used instead the default is to listen on localhost (not reachable to other devices) on port 5000.
from flask import Flask app = Flask(__name__) @app.route("/path", methods=['GET']) def main(): print(“Hello, world!”) if __name__ == "__main__": app.run(host='0.0.0.0', port='5001')
When a user navigates to this URL in their browser, it will display "Hello, world!".
Bringing it together
Once you have set up your virtual environment and written your Python script, you must first activate the virtual environment:
Once activated, you will run your Python script:
Now, your script is running and listening for requests. To disable, simply press ctrl+c, and enter the following to deactivate your virtual environment:
If you build this on a server that resides within your network, the link will only be available to users within the network, either physically or by VPN. If run from a server on the web, such as AWS, it will be available globally, so you will want to add in authentication and authorization mechanisms to prevent unknown actors from executing the script.
This is a very simple example, with a great deal of flexibility. It can be used to issue API calls for Mulesoft/Dell Boomi/Informatica tasks you've already created, make direct API calls to the Anaplan API, or any other activity that is scriptable.