Skip to content

Commit

Permalink
Source Salesforce: Convert to airbyte-lib (#33936)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Reuter committed Jan 9, 2024
1 parent 94f981c commit e7ff2a1
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
40 changes: 2 additions & 38 deletions airbyte-integrations/connectors/source-salesforce/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,7 @@
#


import sys
import traceback
from datetime import datetime
from typing import List

from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch
from airbyte_cdk.models import AirbyteErrorTraceMessage, AirbyteMessage, AirbyteTraceMessage, TraceType, Type
from source_salesforce import SourceSalesforce


def _get_source(args: List[str]):
catalog_path = AirbyteEntrypoint.extract_catalog(args)
config_path = AirbyteEntrypoint.extract_config(args)
try:
return SourceSalesforce(
SourceSalesforce.read_catalog(catalog_path) if catalog_path else None,
SourceSalesforce.read_config(config_path) if config_path else None,
)
except Exception as error:
print(
AirbyteMessage(
type=Type.TRACE,
trace=AirbyteTraceMessage(
type=TraceType.ERROR,
emitted_at=int(datetime.now().timestamp() * 1000),
error=AirbyteErrorTraceMessage(
message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}",
stack_trace=traceback.format_exc(),
),
),
).json()
)
return None

from source_salesforce.run import run

if __name__ == "__main__":
_args = sys.argv[1:]
source = _get_source(_args)
if source:
launch(source, _args)
run()
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: b117307c-14b6-41aa-9422-947e34922962
dockerImageTag: 2.2.1
dockerImageTag: 2.2.2
dockerRepository: airbyte/source-salesforce
documentationUrl: https://docs.airbyte.com/integrations/sources/salesforce
githubIssueLabel: source-salesforce
Expand Down
5 changes: 5 additions & 0 deletions airbyte-integrations/connectors/source-salesforce/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
extras_require={
"tests": TEST_REQUIREMENTS,
},
entry_points={
"console_scripts": [
"source-salesforce=source_salesforce.run:run",
],
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#


import sys
import traceback
from datetime import datetime
from typing import List

from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch
from airbyte_cdk.models import AirbyteErrorTraceMessage, AirbyteMessage, AirbyteTraceMessage, TraceType, Type
from source_salesforce import SourceSalesforce


def _get_source(args: List[str]):
catalog_path = AirbyteEntrypoint.extract_catalog(args)
config_path = AirbyteEntrypoint.extract_config(args)
try:
return SourceSalesforce(
SourceSalesforce.read_catalog(catalog_path) if catalog_path else None,
SourceSalesforce.read_config(config_path) if config_path else None,
)
except Exception as error:
print(
AirbyteMessage(
type=Type.TRACE,
trace=AirbyteTraceMessage(
type=TraceType.ERROR,
emitted_at=int(datetime.now().timestamp() * 1000),
error=AirbyteErrorTraceMessage(
message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}",
stack_trace=traceback.format_exc(),
),
),
).json()
)
return None


def run():
_args = sys.argv[1:]
source = _get_source(_args)
if source:
launch(source, _args)
3 changes: 2 additions & 1 deletion docs/integrations/sources/salesforce.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Now that you have set up the Salesforce source connector, check out the followin

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|
| 2.2.2 | 2024-01-04 | [33936](https://github.com/airbytehq/airbyte/pull/33936) | Prepare for airbyte-lib |
| 2.2.1 | 2023-12-12 | [33342](https://github.com/airbytehq/airbyte/pull/33342) | Added new ContentDocumentLink stream |
| 2.2.0 | 2023-12-12 | [33350](https://github.com/airbytehq/airbyte/pull/33350) | Sync streams concurrently on full refresh |
| 2.1.6 | 2023-11-28 | [32535](https://github.com/airbytehq/airbyte/pull/32535) | Run full refresh syncs concurrently |
Expand Down Expand Up @@ -273,4 +274,4 @@ Now that you have set up the Salesforce source connector, check out the followin
| 0.1.1 | 2021-09-21 | [6209](https://github.com/airbytehq/airbyte/pull/6209) | Fix bug with pagination for BULK API |
| 0.1.0 | 2021-09-08 | [5619](https://github.com/airbytehq/airbyte/pull/5619) | Salesforce Aitbyte-Native Connector |

</HideInUI>
</HideInUI>

0 comments on commit e7ff2a1

Please sign in to comment.