External Systems
About Foundry Sources
The External Systems library is Python SDK built as an interface to reference Foundry Sources from code.
Installation
You can install the Python package using pip:
pip install external-systems
Basic Source Usage
HTTP Client
For REST based sources, a preconfigured HTTP client is provided built on top of the Python requests library. For on-prem systems using Agent Proxy the client will be pre-configured with the corresponding proxy
from external_systems.sources import Source, HttpsConnection
from requests import Session
my_source: Source = ...
https_connection: HttpsConnection = my_source.get_https_connection()
source_url: str = https_connection.url
http_client: Session = https_connection.get_client()
response = http_client.get(source_url + "/api/v1/example/", timeout=10)
Secrets
Source secrets can be referenced using get_secret("<secret_name>") on the source.
from external_systems.sources import Source
my_source: Source = ...
some_secret: str = my_source.get_secret("SECRET_NAME")
For sources using session credentials we support credentials generation and refresh management. This can be done by using get_session_credentials which supports S3 and BigQuery sources.
Session credentials may not be available in all Foundry runtime environments
from external_systems.sources import Source, Refreshable, SourceCredentials, AwsCredentials
s3_source: Source = ...
refreshable_credentials: Refreshable[SourceCredentials] = s3_source.get_session_credentials()
session_credentials: SourceCredentials = refreshable_credentials.get()
if not isinstance(session_credentials, AwsCredentials):
raise ...
On-prem Connectivity with Foundry Agent Proxy
Socket
For non-HTTP connections to external systems that require connections through Foundry's agent proxy, a pre-configured socket is provided.
On-Prem SFTP Server Example
For this example we'll be using the fabric library
import fabric
from external_systems.sources import Source
from socket import socket
SFTP_HOST = <sftp_host>
SFTP_PORT = <sftp_port>
on_prem_proxied_source: Source = ...
username: str = on_prem_sftp_server.get_secret("username")
password: str = on_prem_sftp_server.get_secret("password")
proxy_socket: socket = source.create_socket(SFTP_HOST, SFTP_PORT)
with fabric.Connection(
SFTP_HOST,
user=username,
port=SFTP_PORT,
connect_kwargs={
"password": password,
"sock": proxy_socket,
},
) as conn:
sftp = conn.sftp()
file_list = sftp.listdir(".")
Authenticated Proxy URI
For more granular use cases a pre-authenticated proxy URI is provided to allow connections to on-prem external systems.
Example
We'll be using the httpx library.
import httpx
from external_systems.sources import Source
on_prem_system: Source = ...
authenticated_proxy_uri: str = on_prem_system.get_https_proxy_uri()
with httpx.Client(proxy=authenticated_proxy_uri) as client:
...
Metadata
Release files for external-systems 0.112.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| external_systems-0.112.0.tar.gz | 12.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| external_systems-0.112.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.5 kB
Release files / external_systems-0.112.0.tar.gz
| Download URL | external_systems-0.112.0.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d4d2cc470abc133467fd0f71503f93606abca64c1c3d3e82e3bc324740fbeea
|
|
BLAKE2b-256 checksum How to use checksums |
50ed012876b47db24d7632a05bd4eec79f6021ed7b528ed248331a7ee6608053
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.15 Linux/7.0.0-1013-aws
|
Release files / external_systems-0.112.0-py3-none-any.whl
| Download URL | external_systems-0.112.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d261261f4c82f2d73817509f24a08287955fc9915025499a508673e440c5cc00
|
|
BLAKE2b-256 checksum How to use checksums |
1bc154319832f98e6b648a17403303ab7dbef197857c0858a6463c43510012c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.15 Linux/7.0.0-1013-aws
|