-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add salesforce connector (#1168)
- Loading branch information
1 parent
1a0b737
commit b710baf
Showing
29 changed files
with
1,191 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
Salesforce | ||
========== | ||
Connect Salesforce to your preprocessing pipeline, and batch process Salesforce data using ``unstructured-ingest`` to store structured outputs locally on your filesystem. | ||
|
||
First you'll need to install the Salesforce dependencies as shown here. | ||
|
||
.. code:: shell | ||
pip install "unstructured[salesforce]" | ||
Run Locally | ||
----------- | ||
|
||
.. tabs:: | ||
|
||
.. tab:: Shell | ||
|
||
.. code:: shell | ||
unstructured-ingest \ | ||
salesforce \ | ||
--salesforce-username "$SALESFORCE_USERNAME" \ | ||
--salesforce-consumer-key "$SALESFORCE_CONSUMER_KEY" \ | ||
--salesforce-private-key-path "$SALESFORCE_PRIVATE_KEY_PATH" \ | ||
--salesforce-categories "EmailMessage,Account,Lead,Case,Campaign" \ | ||
--structured-output-dir salesforce-output \ | ||
--num-processes 2 \ | ||
--recursive \ | ||
--verbose | ||
.. tab:: Python | ||
|
||
.. code:: python | ||
import subprocess | ||
command = [ | ||
"unstructured-ingest", | ||
"salesforce", | ||
"--salesforce-username" "$SALESFORCE_USERNAME" | ||
"--salesforce-consumer-key" "$SALESFORCE_CONSUMER_KEY" | ||
"--salesforce-private-key-path" "$SALESFORCE_PRIVATE_KEY_PATH" | ||
"--salesforce-categories" "EmailMessage,Account,Lead,Case,Campaign" | ||
"--structured-output-dir" "salesforce-output" | ||
"--box_app_config", "$BOX_APP_CONFIG_PATH" | ||
"--remote-url", "box://utic-test-ingest-fixtures" | ||
"--structured-output-dir", "box-output" | ||
"--num-processes", "2" | ||
"--recursive", | ||
"--verbose", | ||
] | ||
# Run the command | ||
process = subprocess.Popen(command, stdout=subprocess.PIPE) | ||
output, error = process.communicate() | ||
# Print output | ||
if process.returncode == 0: | ||
print('Command executed successfully. Output:') | ||
print(output.decode()) | ||
else: | ||
print('Command failed. Error:') | ||
print(error.decode()) | ||
Run via the API | ||
--------------- | ||
|
||
You can also use upstream connectors with the ``unstructured`` API. For this you'll need to use the ``--partition-by-api`` flag and pass in your API key with ``--api-key``. | ||
|
||
.. tabs:: | ||
|
||
.. tab:: Shell | ||
|
||
.. code:: shell | ||
unstructured-ingest \ | ||
salesforce \ | ||
--salesforce-username "$SALESFORCE_USERNAME" \ | ||
--salesforce-consumer-key "$SALESFORCE_CONSUMER_KEY" \ | ||
--salesforce-private-key-path "$SALESFORCE_PRIVATE_KEY_PATH" \ | ||
--salesforce-categories "EmailMessage,Account,Lead,Case,Campaign" \ | ||
--structured-output-dir salesforce-output \ | ||
--num-processes 2 \ | ||
--recursive \ | ||
--verbose | ||
--partition-by-api \ | ||
--api-key "<UNSTRUCTURED-API-KEY>" | ||
.. tab:: Python | ||
|
||
.. code:: python | ||
import subprocess | ||
command = [ | ||
"unstructured-ingest", | ||
"salesforce", | ||
"--salesforce-username" "$SALESFORCE_USERNAME" | ||
"--salesforce-consumer-key" "$SALESFORCE_CONSUMER_KEY" | ||
"--salesforce-private-key-path" "$SALESFORCE_PRIVATE_KEY_PATH" | ||
"--salesforce-categories" "EmailMessage,Account,Lead,Case,Campaign" | ||
"--structured-output-dir" "salesforce-output" | ||
"--box_app_config", "$BOX_APP_CONFIG_PATH" | ||
"--remote-url", "box://utic-test-ingest-fixtures" | ||
"--structured-output-dir", "box-output" | ||
"--num-processes", "2" | ||
"--recursive", | ||
"--verbose", | ||
"--partition-by-api", | ||
"--api-key", "<UNSTRUCTURED-API-KEY>", | ||
] | ||
# Run the command | ||
process = subprocess.Popen(command, stdout=subprocess.PIPE) | ||
output, error = process.communicate() | ||
# Print output | ||
if process.returncode == 0: | ||
print('Command executed successfully. Output:') | ||
print(output.decode()) | ||
else: | ||
print('Command failed. Error:') | ||
print(error.decode()) | ||
Additionaly, you will need to pass the ``--partition-endpoint`` if you're running the API locally. You can find more information about the ``unstructured`` API `here <https://github.com/Unstructured-IO/unstructured-api>`_. | ||
|
||
For a full list of the options the CLI accepts check ``unstructured-ingest salesforce --help``. | ||
|
||
NOTE: Keep in mind that you will need to have all the appropriate extras and dependencies for the file types of the documents contained in your data storage platform if you're running this locally. You can find more information about this in the `installation guide <https://unstructured-io.github.io/unstructured/installing.html>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Processes multiple files in a nested folder structure from Salesforce | ||
# through Unstructured's library in 2 processes. | ||
|
||
# Available categories are: Account, Case, Campaign, EmailMessage, Lead | ||
|
||
# Structured outputs are stored in salesforce-output/ | ||
|
||
# Using JWT authorization | ||
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm | ||
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_connected_app.htm | ||
|
||
# private-key-path is the path to the key file | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd "$SCRIPT_DIR"/../../.. || exit 1 | ||
|
||
|
||
PYTHONPATH=. ./unstructured/ingest/main.py \ | ||
salesforce \ | ||
--username "$SALESFORCE_USERNAME" \ | ||
--consumer-key "$SALESFORCE_CONSUMER_KEY" \ | ||
--private-key-path "$SALESFORCE_PRIVATE_KEY_PATH" \ | ||
--categories "EmailMessage,Account,Lead,Case,Campaign" \ | ||
--structured-output-dir salesforce-output \ | ||
--preserve-downloads \ | ||
--reprocess \ | ||
--verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-c constraints.in | ||
-c base.txt | ||
simple-salesforce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.8 | ||
# by the following command: | ||
# | ||
# pip-compile requirements/ingest-salesforce.in | ||
# | ||
attrs==23.1.0 | ||
# via zeep | ||
certifi==2023.7.22 | ||
# via | ||
# -c requirements/base.txt | ||
# -c requirements/constraints.in | ||
# requests | ||
cffi==1.15.1 | ||
# via cryptography | ||
charset-normalizer==3.2.0 | ||
# via | ||
# -c requirements/base.txt | ||
# requests | ||
cryptography==41.0.3 | ||
# via simple-salesforce | ||
idna==3.4 | ||
# via | ||
# -c requirements/base.txt | ||
# requests | ||
isodate==0.6.1 | ||
# via zeep | ||
lxml==4.9.3 | ||
# via | ||
# -c requirements/base.txt | ||
# zeep | ||
platformdirs==3.10.0 | ||
# via zeep | ||
pycparser==2.21 | ||
# via cffi | ||
pyjwt==2.8.0 | ||
# via simple-salesforce | ||
pytz==2023.3 | ||
# via zeep | ||
requests==2.31.0 | ||
# via | ||
# -c requirements/base.txt | ||
# requests-file | ||
# requests-toolbelt | ||
# simple-salesforce | ||
# zeep | ||
requests-file==1.5.1 | ||
# via zeep | ||
requests-toolbelt==1.0.0 | ||
# via zeep | ||
simple-salesforce==1.12.4 | ||
# via -r requirements/ingest-salesforce.in | ||
six==1.16.0 | ||
# via | ||
# isodate | ||
# requests-file | ||
urllib3==1.26.16 | ||
# via | ||
# -c requirements/base.txt | ||
# -c requirements/constraints.in | ||
# requests | ||
zeep==4.2.1 | ||
# via simple-salesforce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.