Get Started with the Open PaaS Platform¶
When integrating external data with the Open PaaS Platform, creating an efficient connector is key. This tutorial will guide you through the process of building a connector using the Python SDK, which allows you to seamlessly ingest data from external sources.
In this tutorial, you will learn how to::
Set up your environment and install the Python SDK.
Create a basic connector to ingest data from an external source.
Use the Python SDK to interact with the Open PaaS Platform.
Set Up Your Environment¶
Before building, ensure your environment is ready:
- You've Python 3.8 or higher. Verify your Python version with:
- A text editor like Visual Studio Code or PyCharm.
- Open PaaS Platform Python SDK installed. If not already, install the SDK with the following command:
Create Your First Connector¶
To start interacting with the Open PaaS Platform and ingest data, you need to create a connector. A connector is a component that helps the Open PaaS Platform communicate with external data sources, such as APIs or databases. In this section of the tutorial, you will create a simple connector that ingests data from an external source into the Open PaaS Platform using the Python SDK.
Understand the Connector
Before writing the code, let’s first understand what this connector will do:
- Authentication: It will authenticate the request to the Open PaaS Platform using the given API key.
- Data Ingestion: It will fetch data from an external source, such as a URL or an API.
- Integration: Finally, it will ingest the fetched data into the Open PaaS Platform, making it available for processing.
Now, that you've understood the basics of connector. Let’s build a simple connector to ingest data from an external source into the Open PaaS Platform.
- Open Visual Studio Code (VS Code) and create a new Python file named connector.py.
- Start by importing the Open PaaS PlatformClient class from the SDK. This class allows you to interact with the Open PaaS Platform.
- Next, you’ll initialize the Open PaaS PlatformClient by passing your API key. This will authenticate your requests to the Open PaaS Platform.
-
Now, let’s create the function that will pull data from an external source. In this case, it's
ingest_data
. This function will use the ingest method of the Open PaaS Platform Client to fetch data from a provided external data source URL. -
Now that you’ve gone through each part of the connector, let’s bring it all together. Below is the complete code for the connector:
from OpenPaaSPlatform_sdk import OpenPaaSPlatformClient #(1) # Initialize the client with your API key client = OpenPaaSPlatformClient(api_key="sk_test_51Hq7dT2gR4kq9pRxyz12345abcde67890fghij") #(2) # Ingest data from an external source def ingest_data(): data = client.ingest("https://api.openpaas.com/v1/ingest") #(3) return data #(4)
In this code:
- (1) The
OpenPaaSPlatform_sdk
is the library provided by the Open PaaS Platform. - (2)
OpenPaaSPlatformClient
is the core class within this SDK that enables interaction with the platform’s API.- You use this to manage tasks like authentication and data operations. An instance of the
OpenPaaSPlatformClient
class (here named client) is created. - It is initialized with the provided API key (sk_test_51Hq7dT2gR4kq9pRxyz12345abcde67890fghij).
- The API key is essential for authentication and grants access to the platform’s services.
- You use this to manage tasks like authentication and data operations. An instance of the
- (3)
client.ingest
encapsulates the logic for pulling data from an external source using the OpenPaaSPlatformClient instance. It interacts with the platform to fetch data from the specified datasource (https://api.openpaas.com/v1/ingest
). - (4) The data fetched from the platform is returned for further use.
- (1) The
By completing this section, you’ve created your first connector that integrates an external data source with the Open PaaS Platform. You can now test this connector to verify that the data is ingested successfully.
Test Your Connector¶
Now that the connector is ready, you can test it.
- Save your connector.py file.
- Open your terminal. Run the following command to execute the script:
- If everything is working correctly, you will see a message like this in your terminal: This confirms that your connector has successfully ingested the data from the external source into the Open PaaS Platform.
By completing this section, you’ve tested your first connector that ingests data. You can now experiment with this connector and explore ways to enhance it for more complex data ingestion scenarios.
Next Steps¶
Congratulations! You've successfully:
- Installed the Python SDK.
- Built and tested your first connector.
To explore advanced features, check out the Advanced SDK Documentation
Keep experimenting to master the platform and expand your skills!