Skip to content

Commit

Permalink
Marcos/destination firebolt up sdk (#38060)
Browse files Browse the repository at this point in the history
Co-authored-by: ptiurin <petro.tiurin@firebolt.io>
Co-authored-by: Petro Tiurin <93913847+ptiurin@users.noreply.github.com>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
4 people committed May 8, 2024
1 parent 7309360 commit 327e010
Show file tree
Hide file tree
Showing 12 changed files with 3,294 additions and 86 deletions.
29 changes: 0 additions & 29 deletions airbyte-integrations/connectors/destination-firebolt/Dockerfile

This file was deleted.

Expand Up @@ -9,7 +9,7 @@ For information about how to use this connector within Airbyte, see [the documen

**To iterate on this connector, make sure to complete this prerequisites section.**

#### Minimum Python version required `= 3.7.0`
#### Minimum Python version required `= 3.8.0`

#### Build & Activate Virtual Environment and install dependencies

Expand Down
Expand Up @@ -12,24 +12,37 @@
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConfiguredAirbyteCatalog, DestinationSyncMode, Status, Type
from firebolt.client import DEFAULT_API_URL
from firebolt.client.auth import UsernamePassword
from firebolt.client.auth import Auth, ClientCredentials, UsernamePassword
from firebolt.db import Connection, connect

from .writer import create_firebolt_wirter

logger = getLogger("airbyte")


def _determine_auth(key: str, secret: str) -> Auth:
"""
Determine between new auth based on key and secret or legacy email based auth.
"""
if "@" in key:
# email auth can only be used with UsernamePassword
return UsernamePassword(key, secret)
else:
return ClientCredentials(key, secret)


def parse_config(config: json, logger: Optional[AirbyteLogger] = None) -> Dict[str, Any]:
"""
Convert dict of config values to firebolt.db.Connection arguments
:param config: json-compatible dict of settings
:param logger: AirbyteLogger instance to print logs.
:return: dictionary of firebolt.db.Connection-compatible kwargs
"""
# We should use client_id/client_secret, this code supports username/password for legacy users
auth = _determine_auth(config.get("client_id", config.get("username")), config.get("client_secret", config.get("password")))
connection_args = {
"database": config["database"],
"auth": UsernamePassword(config["username"], config["password"]),
"auth": auth,
"api_endpoint": config.get("host", DEFAULT_API_URL),
"account_name": config.get("account"),
}
Expand Down
Expand Up @@ -8,20 +8,20 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Firebolt Spec",
"type": "object",
"required": ["username", "password", "database"],
"required": ["client_id", "client_secret", "account", "database", "engine"],
"additionalProperties": false,
"properties": {
"username": {
"client_id": {
"type": "string",
"title": "Username",
"description": "Firebolt email address you use to login.",
"examples": ["username@email.com"],
"title": "Client ID",
"description": "Firebolt service account ID.",
"examples": ["bbl9qth066hmxkwyb0hy2iwk8ktez9dz"],
"order": 0
},
"password": {
"client_secret": {
"type": "string",
"title": "Password",
"description": "Firebolt password.",
"title": "Client Secret",
"description": "Firebolt secret, corresponding to the service account ID.",
"airbyte_secret": true,
"order": 1
},
Expand All @@ -44,7 +44,7 @@
"engine": {
"type": "string",
"title": "Engine",
"description": "Engine name or url to connect to."
"description": "Engine name to connect to."
},
"loading_method": {
"type": "object",
Expand Down
Expand Up @@ -2,9 +2,11 @@ data:
connectorSubtype: database
connectorType: destination
definitionId: 18081484-02a5-4662-8dba-b270b582f321
dockerImageTag: 0.1.1
dockerImageTag: 0.2.0
dockerRepository: airbyte/destination-firebolt
githubIssueLabel: destination-firebolt
connectorBuildOptions:
baseImage: docker.io/airbyte/python-connector-base:1.2.0@sha256:c22a9d97464b69d6ef01898edf3f8612dc11614f05a84984451dde195f337db9
icon: firebolt.svg
license: MIT
name: Firebolt
Expand Down

0 comments on commit 327e010

Please sign in to comment.