62 lines
1.6 KiB
Markdown
62 lines
1.6 KiB
Markdown
# Provider Manager API Documentation
|
|
|
|
## Overview
|
|
The `ProviderManager` class provides functionality for managing AI service providers, including:
|
|
- Adding providers to tenants
|
|
- Removing providers
|
|
- Querying provider information
|
|
- Bulk operations for all tenants
|
|
|
|
## Class Methods
|
|
|
|
### Provider Addition
|
|
- `add_provider_for_tenant(tenant_id, public_key_pem, provider_config)`
|
|
- Adds a provider to a tenant
|
|
- Encrypts API keys using tenant's public key
|
|
- Supports different provider types
|
|
|
|
**Parameters:**
|
|
- `tenant_id`: Target tenant UUID
|
|
- `public_key_pem`: Tenant's public key for encryption
|
|
- `provider_config`: Dictionary containing provider configuration
|
|
|
|
**Required Fields in provider_config:**
|
|
```python
|
|
{
|
|
"provider_name": str, # Unique provider name
|
|
"config": dict # Provider configuration including API keys
|
|
}
|
|
```
|
|
|
|
### Bulk Operations
|
|
- `add_providers_for_all_tenants(config_path)`
|
|
- `add_providers_for_tenant(tenant_name, config_path)`
|
|
|
|
### Provider Removal
|
|
- `delete_provider_for_tenant(tenant_id, provider_name)`
|
|
- `delete_providers_for_tenant(tenant_id)`
|
|
|
|
### Query Methods
|
|
- `get_providers_for_tenant(tenant_id)`
|
|
- Returns all providers for a tenant
|
|
- Format:
|
|
```python
|
|
[
|
|
{
|
|
"id": str,
|
|
"provider_name": str,
|
|
"provider_type": str,
|
|
"is_valid": bool
|
|
}
|
|
]
|
|
```
|
|
|
|
## Security Considerations
|
|
- API keys are encrypted using tenant's public key
|
|
- Detailed logging of all operations
|
|
- Validation of required fields
|
|
|
|
## Error Handling
|
|
- Raises exceptions for invalid configurations
|
|
- Logs all errors with detailed context
|