Skip to content

raft-tech/rdp-sdk-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RDP SDK for Python

The RDP SDK for Python is part of the unified SDK family for client applications interacting with Raft Data Platform (RDP). It provides async Python APIs, configuration, authentication, TLS, logging, and timeout helpers for the RDP API surface.

For platform concepts, API guides, and integration details, see https://developer.teamraft.com.

Installation

Python 3.12 or newer is required. Install with the Python interpreter you plan to use:

python3 -m pip install rdp-sdk-python

If your system has multiple Python versions, use the Python 3.12+ binary directly, for example python3.12 -m pip install rdp-sdk-python.

Quick Start

export RDP_SERVER_URL=https://rdp.example.com
export RDP_API_KEY=your-api-key
import asyncio

import rdp_sdk
import structlog
from raft.wdm.v1.service import object_service_pb2


async def main() -> None:
    # Load RDP_SERVER_URL and authentication from the environment.
    cfg = rdp_sdk.load_config(logger=structlog.get_logger())

    # Create a client from the loaded config.
    async with rdp_sdk.Client.from_config(cfg, timeout=10.0) as client:
        # Request the first 10 WDM objects.
        response = await client.object_service.search_objects(
            object_service_pb2.SearchObjectsRequest(page_size=10),
        )

        if not response.objects:
            print("No WDM objects found.")
            return

        for obj in response.objects:
            print(f"{obj.id}\t{obj.name}")


asyncio.run(main())

For more examples, see examples.

Configuration

load_config() reads connection settings from environment variables and returns a validated RdpConfig. Pass a structlog-compatible logger for validation warnings, and pass env_path to load a dotenv file before reading the process environment.

Variable Required Description
RDP_SERVER_URL No Base RDP endpoint. Defaults to https://rdp.local; use scheme and host only.
RDP_SERVER_PORT No Optional port override for the endpoint.
TLS_SKIP_VERIFY No Set to true only for development or test endpoints with self-signed certificates.
RDP_PROTOCOL No Optional ConnectRPC protocol override: connect, grpc, grpc_web, or grpc-web.

Authentication

API key authentication is the preferred method for client applications. Use OAuth2 client credentials only when your deployment requires token exchange.

Method Variables Request behavior
API key RDP_API_KEY Sends the value on each request as an API key header.
OAuth2 client credentials RDP_CLIENT_ID, RDP_CLIENT_SECRET Fetches a token from {RDP_SERVER_URL}/api/v1/auth/token and sends it as a bearer token.

Providing both auth methods is an error. If neither method is configured, requests are sent without auth and the SDK logs a warning.

Functional Configuration

Pass keyword arguments to Client(...), or use Client.from_config(cfg, **overrides) to layer programmatic values on top of a loaded RdpConfig. Overrides win over values loaded from the environment.

For direct construction:

logger = structlog.get_logger()

async with rdp_sdk.Client(
    "https://rdp.example.com",
    api_key="your-api-key",
    timeout=10.0,
    logger=logger,
) as client:
    # call generated service clients
    ...

For environment-first configuration with programmatic overrides:

cfg = rdp_sdk.load_config(env_path=".env.local", logger=logger)

async with rdp_sdk.Client.from_config(
    cfg,
    timeout=10.0,
) as client:
    # call generated service clients
    ...

Use client_id and client_secret instead of api_key only when your deployment requires OAuth2 client credentials. Use tls_skip_verify=True only for development or test endpoints with self-signed certificates. Pass protocol=... only when you need to force a specific ConnectRPC protocol.

About

RDP SDK for Python

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages