AmorphicApiClient¶
- class openapi_client.amorphic_api_client.AmorphicApiClient(configuration, role_id, custom_logger=None)[source]
Bases:
ApiClientCustom API client for Amorphic API that extends the base ApiClient
- __init__(configuration, role_id, custom_logger=None)[source]
Initialize the Amorphic API client with the given configuration and role ID
- Parameters:
configuration (Configuration) – The configuration object containing host, API key, etc.
role_id (str) – The role ID for authentication
custom_logger (Optional[logging.Logger]) – Custom logger instance. If not provided, a default logger will be created.
- Raises:
ValueError – If the API version is not compatible with the required version range
- classmethod create_with_auth(host, role_id, ssl_ca_cert=None, debug=False, aws_profile=None, env_var=None, ssm_parameter=None, secret_arn=None, token=None, custom_logger=None)[source]
Factory method to create AmorphicApiClient with flexible authentication
- Parameters:
host (str) – API host URL
role_id (str) – Role ID for authentication
ssl_ca_cert (Optional[str]) – SSL CA certificate path
debug (bool) – Enable debug mode
aws_profile (Optional[str]) – AWS profile for local development
env_var (Optional[str]) – Environment variable name containing token
ssm_parameter (Optional[str]) – SSM parameter name containing token
secret_arn (Optional[str]) – Secrets Manager secret ARN
token (Optional[str]) – Direct token value
custom_logger (Optional[logging.Logger]) – Custom logger instance
- Returns:
Configured client instance
- Return type:
AmorphicApiClient
- Raises:
ValueError – If no token source is configured
- get_system_information(role_id)[source]
Get system information from the Amorphic API
- Parameters:
role_id (str) – The role ID for authentication. Must be provided.
- Returns:
The system information response
- Return type:
SystemInformation
- Raises:
ValueError – If role_id is None or empty
ApiException – If the API call fails
Overview:
The AmorphicApiClient is an enhanced API client that extends the base OpenAPI ApiClient to provide additional functionality for interacting with the Amorphic Data Platform APIs. It includes system information retrieval, authentication, and role management capabilities.
Key Features:
Enhanced Authentication: Built-in support for multiple token sources
System Information: Automatic retrieval of platform information during initialization
Basic Usage:
import certifi
from openapi_client.amorphic_api_client import AmorphicApiClient
from openapi_client.api.datasets_api import DatasetsApi
# Create client with environment variable token
client = AmorphicApiClient.create_with_auth(
host="https://your-instance.amorphic.com/api",
role_id="your-role-id",
ssl_ca_cert=certifi.where(),
debug=False,
aws_profile=None,
env_var='PAT_TOKEN'
)
# Use with any API
datasets_api = DatasetsApi(client)
# Example: List datasets
datasets = datasets_api.list_datasets(role_id="your-role-id")
Authentication Options:
# Option 1: Environment variable
client = AmorphicApiClient.create_with_auth(
host="https://api.example.com",
role_id="role-123",
ssl_ca_cert=certifi.where(),
debug=False,
aws_profile=None,
env_var='PAT_TOKEN'
)
# Option 2: AWS SSM Parameter Store
client = AmorphicApiClient.create_with_auth(
host="https://api.example.com",
role_id="role-123",
ssl_ca_cert=certifi.where(),
debug=False,
aws_profile='myprofile',
ssm_parameter='/myapp/api/token'
)
# Option 3: AWS Secrets Manager
client = AmorphicApiClient.create_with_auth(
host="https://api.example.com",
role_id="role-123",
ssl_ca_cert=certifi.where(),
debug=False,
aws_profile=None,
secret_arn='arn:aws:secretsmanager:us-east-1:123456789012:secret:mytoken'
)
# Option 4: Direct token
client = AmorphicApiClient.create_with_auth(
host="https://api.example.com",
role_id="role-123",
ssl_ca_cert=certifi.where(),
debug=False,
aws_profile=None,
token='your-direct-token'
)