Abhishek Agrawal
09/26/2024, 1:31 AMuser
09/26/2024, 1:31 AM[+ New connector]
on the top right. 3. You will be asked for the display name, the Docker repository name (repository + image name), tag, and documentation URL for that connector. Once this is filled, you will see your connector in the UI and your team will be able to use it, from the UI and Airbyte's API too. Note that this new connector could just be an updated version of an existing connector that you adapted to your specific edge case. Anything is possible! [source](https://docs.airbyte.com/integrations/custom-connectors#adding-your-connectors-in-the-ui) When using Airbyte on Kubernetes, the repository name must be a valid Kubernetes name. That is, it must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc'). Other names will work locally on Docker but cause an error on Kubernetes (Internal Server Error: Get Spec job failed). [source](https://docs.airbyte.com/integrations/custom-connectors#adding-your-connectors-in-the-ui) Please note that custom connectors are currently exclusive to Airbyte Open-Source deployments. However, there are plans for their release on Airbyte Cloud, scheduled for January 2024. You can track the progress on this development [here](https://github.com/orgs/airbytehq/projects/37?pane=issue&itemId=45471174). [source](https://docs.airbyte.com/integrations/custom-connectors) If you'd like to ask for a new connector, you can request it directly [here](https://github.com/airbytehq/airbyte/discussions/new?category=new-connector-request). [source](https://docs.airbyte.com/integrations/custom-connectors)Abhishek Agrawal
09/26/2024, 1:32 AMuser
09/26/2024, 1:32 AMuser
09/26/2024, 1:32 AMAbhishek Agrawal
09/26/2024, 1:36 AMuser
09/26/2024, 1:36 AMuser
09/26/2024, 1:37 AMsource.py
file is crucial when creating a custom connector in Airbyte. It contains the implementation of your connector and defines the streams (endpoints) you want to hit. Here's what you typically need: 1. Imports: Import necessary modules and packages. This includes requests
, logging
, AbstractSource
, Stream
, HttpStream
, and any other dependencies your connector might need. 2. Connector Class: Define a class for your connector that inherits from AbstractSource
. This class should implement methods like check_connection
and streams
. The check_connection
method is used to verify if the connection to the data source is successful. The streams
method returns a list of streams (endpoints) that the connector can pull data from. 3. Stream Classes: For each endpoint you want to hit, define a class that inherits from HttpStream
or Stream
. This class should implement methods like path
, parse_response
, and next_page_token
. The path
method defines the API endpoint to hit, parse_response
parses the API response, and next_page_token
handles pagination. Here's a sample code snippet from the knowledge sources: python from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple import requests import logging from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream from airbyte_cdk.sources.streams.http import HttpStream logger = logging.getLogger("airbyte") class SourcePythonHttpExample(AbstractSource): def check_connection(self, logger, config) -> Tuple[bool, any]: # Implementation of connection check logic pass def streams(self, config: Mapping[str, Any]) -> List[Stream]: # Return list of streams pass class Pokemon(HttpStream): url_base = "<https://pokeapi.co/api/v2/>" primary_key = None def __init__(self, pokemon_name: str, **kwargs): super().__init__(**kwargs) self.pokemon_name = pokemon_name def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: # Handle pagination pass def path(self) -> str: # Define API endpoint pass def parse_response(self) -> Iterable[Mapping]: # Parse API response pass
[source](https://docs.airbyte.com/connector-development/tutorials/cdk-speedrun#define-connector-inputs) Please note that the actual implementation of these methods will depend on the specifics of the API you're connecting to.