Files
motia-iii/steps/advoware_proxy/advoware_api_proxy_get_step.py
bsiggel a24282c346 Migrate Advoware Proxy steps from old-motia
- Added services/advoware.py: Advoware API client with Redis token caching
- Added advoware_proxy steps (GET, POST, PUT, DELETE)
- Updated pyproject.toml: added aiohttp, redis, python-dotenv
- Updated iii-config.yaml: fixed ExecModule command to use full path
- Created MIGRATION_STATUS.md: documentation of migration progress

All 4 proxy endpoints registered successfully:
- GET /advoware/proxy
- POST /advoware/proxy
- PUT /advoware/proxy
- DELETE /advoware/proxy
2026-03-01 21:47:43 +00:00

56 lines
1.6 KiB
Python

"""Advoware API Proxy - GET requests"""
from typing import Any
from motia import FlowContext, http, ApiRequest, ApiResponse
from services.advoware import AdvowareAPI
config = {
"name": "Advoware Proxy GET",
"description": "Universal proxy for Advoware API (GET requests)",
"flows": ["advoware"],
"triggers": [
http("GET", "/advoware/proxy")
],
"enqueues": [],
}
async def handler(request: ApiRequest, ctx: FlowContext[Any]) -> ApiResponse:
"""
Proxy GET requests to Advoware API.
Query parameters:
- endpoint: Advoware API endpoint (required)
- any other params are forwarded to Advoware
"""
try:
# Extract endpoint from query parameters
endpoint = request.query_params.get('endpoint', '')
if not endpoint:
return ApiResponse(
status=400,
body={'error': 'Endpoint required as query parameter'}
)
# Initialize Advoware client
advoware = AdvowareAPI(ctx)
# Forward all query params except 'endpoint'
params = {k: v for k, v in request.query_params.items() if k != 'endpoint'}
ctx.logger.info(f"Proxying GET request to Advoware: {endpoint}")
result = await advoware.api_call(
endpoint,
method='GET',
params=params
)
return ApiResponse(status=200, body={'result': result})
except Exception as e:
ctx.logger.error(f"Proxy error: {e}")
return ApiResponse(
status=500,
body={'error': 'Internal server error', 'details': str(e)}
)