SampleDest
. When you’re building your own destination, you can swap out the SampleDest
name for the real name of your new destination.
- Create a directory for the new destination
- Define custom destination class
- Add main function
- Add your destination to the UI (optional)
- Test your destination
1. Create a directory for the new destination
In themage_integrations/destinations/
directory, add a new directory named after your destination.
Use snake case and lowercase for your directory name: mage_integrations/destinations/sample_dest/
.
In this new directory, create the following subdirectories and files:
mage_integrations/destinations/sample_dest/templates/config.json
mage_integrations/destinations/sample_dest/__init__.py
mage_integrations/destinations/sample_dest/README.md
Templates folder
This folder contains a sample configuration JSON file that’s displayed to the user when they are setting up a synchronization using this destination. Theconfig.json
file contains keys and values that are used to configure the
behavior of the destination as well as credentials to authenticate requests to the destination.
Naming convention
You must use the exact filenameconfig.json
.
Examples
__init__.py
This is where majority of the destination logic will exist.
Examples
mage_integrations/destinations/amazon_s3/__init__.py
README.md
Document how to configure and use your destination in the README.md
file.
2. Define custom destination class
In themage_integrations/destinations/sample_dest/__init__.py
,
create a new class named after your destination and subclass the
base destination class.
If you’re adding a destination for a SQL data warehouse or database, you can subclass the
base sql destination class
Override the export_batch_data
method
The base Destination
class has an instance method called export_batch_data
. Here is the interface:
3. Add main function
In the filemage_integrations/destinations/sample_dest/__init__.py
, add the main function to the bottom of the file
like below:
4. Add your destination to the UI (optional)
Add the new destination to theDESTINATIONS
list constant in this file: https://github.com/mage-ai/mage-ai/blob/master/mage_ai/data_integrations/destinations/constants.py
5. Test your desination
Follow this doc to test your new destination. To test the destination in the UI, you can install your updatedmage_integrations
module by running the following commands in Mage terminal: