A python client to interact with the ETP server in with a websocket connection
Project description
py-etp-client
An etp client python module to make an etp websocket connexion
installation :
Pip:
pip install py-etp-client
Poetry
poetry add py-etp-client
Usage :
Check example for more information
Interactive client (in example folder):
You can for example run a interactive client with the following code :
Install :
poetry install
Run the client :
poetry run client
Configuration and authetication
You can configure the client with a configuration file (yaml or json) or directly in code. You can also use different authentication methods :
- Basic authentication (username and password)
- OAuth2 (client ID and secret)
- Azure AD (client ID and secret)
- AWS Cognito (user pool ID and app client ID)
- GCP OAuth (service account key)
- Bearer token (pre-fetched token)
It is also possible to create configurations using environment variables.
Server Configuration
These environment variables configure the ETP server connection and behavior:
| Environment Variable | Description |
|---|---|
SERVER__ID |
Unique identifier for the server configuration |
SERVER_NAME |
Human-readable name for the server configuration |
SERVER_URL |
ETP server URL (including protocol and port) |
SERVER_TIMEOUT |
Connection timeout in seconds |
SERVER_MAX_WEB_SOCKET_FRAME_PAYLOAD_SIZE |
Maximum WebSocket frame payload size in bytes |
SERVER_MAX_WEB_SOCKET_MESSAGE_PAYLOAD_SIZE |
Maximum WebSocket message payload size in bytes |
SERVER_VERIFY_SSL |
Whether to verify SSL certificates |
SERVER_AUTO_RECONNECT |
Whether to automatically reconnect on connection loss |
SERVER_USE_TRANSACTIONS |
Whether to use ETP transactions |
SERVER_SUPPORTED_DATA_OBJECTS |
List of supported ETP data object types |
SERVER_SUPPORTED_PROTOCOLS |
List of supported ETP protocol versions |
SERVER_ADDITIONAL_HEADERS |
Additional HTTP headers to include in requests |
SERVER_ACL_OWNERS |
OSDU ACL owners list |
SERVER_ACL_VIEWERS |
OSDU ACL viewers list |
SERVER_LEGAL_TAGS |
OSDU legal tags list |
SERVER_DATA_COUNTRIES |
OSDU data countries list |
SERVER_AUTH_METHOD |
Authentication method to use (e.g., basic, oauth2, azure, aws, gcp, bearer) |
Basic Authentication
Configure HTTP Basic Authentication credentials:
| Environment Variable | Description |
|---|---|
BASIC_USERNAME |
Username for basic authentication |
BASIC_PASSWORD |
Password for basic authentication |
OAuth2 Authentication
Configure OAuth2 client credentials flow:
| Environment Variable | Description |
|---|---|
OAUTH2_CLIENT_ID |
OAuth2 client ID |
OAUTH2_CLIENT_SECRET |
OAuth2 client secret |
OAUTH2_REFRESH_TOKEN |
OAuth2 refresh token (optional) |
OAUTH2_TOKEN_URL |
OAuth2 token endpoint URL |
OAUTH2_SCOPE |
OAuth2 scopes (space-separated) |
Azure Active Directory Authentication
Configure Azure AD authentication:
| Environment Variable | Description |
|---|---|
AZUREAD_TENANT_ID |
Azure AD tenant ID |
AZUREAD_CLIENT_ID |
Azure AD application (client) ID |
AZUREAD_CLIENT_SECRET |
Azure AD client secret |
AZUREAD_SCOPE |
Azure AD scopes (space-separated) |
AWS Cognito Authentication
Configure AWS Cognito authentication:
| Environment Variable | Description |
|---|---|
AWSCOGNITO_USER_POOL_ID |
AWS Cognito user pool ID |
AWSCOGNITO_APP_CLIENT_ID |
AWS Cognito app client ID |
AWSCOGNITO_CLIENT_SECRET |
AWS Cognito app client secret |
AWSCOGNITO_AWS_REGION |
AWS region for Cognito |
AWSCOGNITO_USERNAME |
Cognito username |
AWSCOGNITO_PASSWORD |
Cognito password |
AWSCOGNITO_REFRESH_TOKEN |
Cognito refresh token (optional) |
Google Cloud Platform Authentication
Configure GCP OAuth2 authentication:
| Environment Variable | Description |
|---|---|
GCPO_GCP_PROJECT_ID |
GCP project ID |
GCPO_SERVICE_ACCOUNT_KEY |
GCP service account key (JSON string or file path) |
GCPO_SCOPE |
GCP OAuth2 scopes (space-separated) |
Bearer Token Authentication
Configure static bearer token authentication:
| Environment Variable | Description |
|---|---|
BEARERTOKEN_CACHED_TOKEN |
Cached authentication token |
BEARERTOKEN_TOKEN_EXPIRES_AT |
Token expiration time (epoch time) |
Usage
Setting Environment Variables
You can set these environment variables in several ways:
-
System environment variables:
export SERVER_URL=wss://example.com/etp export SERVER_TIMEOUT=60
-
.envfile (recommended for development):SERVER_URL=wss://example.com/etp SERVER_TIMEOUT=60 AZUREAD_TENANT_ID=your-tenant-id AZUREAD_CLIENT_ID=your-client-id -
Programmatically:
import os os.environ['SERVER_URL'] = 'wss://example.com/etp'
Loading from Environment
from py_etp_client.etpconfig import ServerConfig
# Load configuration from environment variables
config = ServerConfig.from_env()
Complex Data Types
For list and dictionary fields, you can provide JSON strings:
export SERVER_SUPPORTED_DATA_OBJECTS='["resqml20.obj_Well", "resqml20.obj_WellboreGeometry"]'
export SERVER_ADDITIONAL_HEADERS='{"data-partition-id": "opendes", "Authorization": "Bearer token"}'
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_etp_client-1.1.0.tar.gz.
File metadata
- Download URL: py_etp_client-1.1.0.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b6f210941b323adac74f5fa52296051e24a9ae1cf05a45bbc1a1b238f76733
|
|
| MD5 |
21965fc671990a95c7a8598414371019
|
|
| BLAKE2b-256 |
d139cd1eff515142084dab3cc7514f79128ef7ed9e1d588e6c73c773bae1a796
|
File details
Details for the file py_etp_client-1.1.0-py3-none-any.whl.
File metadata
- Download URL: py_etp_client-1.1.0-py3-none-any.whl
- Upload date:
- Size: 58.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12b9369adbf9340b83ab62883562e9e06d1fe1f2a6aa1332daa1a3483cd50bca
|
|
| MD5 |
f657ec8744bd056633260395c1ef6431
|
|
| BLAKE2b-256 |
f40387c2f0b68944b9474e7017e5e1bcd197390c1b84d8ea3188582fdc00fe34
|