Skip to main content

A Python library for interacting with Foundry Sources

Project description

External Systems

PyPI - Python Version PyPI License Autorelease

[!WARNING] This SDK is incubating and subject to change.

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:
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

external_systems-0.111.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

external_systems-0.111.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file external_systems-0.111.0.tar.gz.

File metadata

  • Download URL: external_systems-0.111.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.8.0-1040-aws

File hashes

Hashes for external_systems-0.111.0.tar.gz
Algorithm Hash digest
SHA256 2da2f4205ceb2ba7ec51fbe22ae56d7f59d02e05e7caca19d1bb0e7612cd40a0
MD5 54acbac22e795177669263a70d17a22a
BLAKE2b-256 996faf697bbd6aea131cf85a6f40bdf240853e504ac6079283a757ef3b1780dc

See more details on using hashes here.

File details

Details for the file external_systems-0.111.0-py3-none-any.whl.

File metadata

  • Download URL: external_systems-0.111.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.8.0-1040-aws

File hashes

Hashes for external_systems-0.111.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d57677faaa015e43097579948ffd5e865c68a9f69a06ed7f235e1585188ddce9
MD5 e0d852172415f86b6583b0a04b155012
BLAKE2b-256 9c0199d050ab2db3e9329e7ee1a3eee61f36c2fdcb6b921de379c19449782182

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page