|
| 1 | +import asyncio |
| 2 | +import os |
| 3 | +from conductor.asyncio_client.adapters import ApiClient |
| 4 | +from conductor.asyncio_client.configuration import Configuration |
| 5 | +from conductor.asyncio_client.orkes.orkes_clients import OrkesClients |
| 6 | + |
| 7 | + |
| 8 | +async def main(): |
| 9 | + """ |
| 10 | + Example of configuring async client with proxy settings. |
| 11 | + """ |
| 12 | + |
| 13 | + # Method 1: Configure proxy via Configuration constructor parameters |
| 14 | + |
| 15 | + # Basic proxy configuration |
| 16 | + config = Configuration( |
| 17 | + server_url="https://play.orkes.io/api", # Or your Conductor server URL |
| 18 | + proxy="http://proxy.company.com:8080", # Your proxy server |
| 19 | + proxy_headers={ |
| 20 | + "Authorization": "Bearer your-proxy-token", # Optional proxy auth |
| 21 | + "User-Agent": "Conductor-Python-Async-SDK/1.0" |
| 22 | + } |
| 23 | + ) |
| 24 | + |
| 25 | + # Method 2: Configure proxy via environment variables |
| 26 | + |
| 27 | + # Set environment variables (you would typically do this in your shell or .env file) |
| 28 | + os.environ["CONDUCTOR_SERVER_URL"] = "https://play.orkes.io/api" |
| 29 | + os.environ["CONDUCTOR_PROXY"] = "http://proxy.company.com:8080" |
| 30 | + os.environ["CONDUCTOR_PROXY_HEADERS"] = '{"Authorization": "Bearer your-proxy-token"}' |
| 31 | + |
| 32 | + # Configuration will automatically pick up environment variables |
| 33 | + config_env = Configuration() |
| 34 | + |
| 35 | + # Method 3: Different proxy types |
| 36 | + |
| 37 | + # HTTP proxy |
| 38 | + http_config = Configuration( |
| 39 | + server_url="https://play.orkes.io/api", |
| 40 | + proxy="http://proxy.company.com:8080" |
| 41 | + ) |
| 42 | + |
| 43 | + # HTTPS proxy |
| 44 | + https_config = Configuration( |
| 45 | + server_url="https://play.orkes.io/api", |
| 46 | + proxy="https://proxy.company.com:8080" |
| 47 | + ) |
| 48 | + |
| 49 | + # SOCKS5 proxy |
| 50 | + socks5_config = Configuration( |
| 51 | + server_url="https://play.orkes.io/api", |
| 52 | + proxy="socks5://proxy.company.com:1080" |
| 53 | + ) |
| 54 | + |
| 55 | + # SOCKS4 proxy |
| 56 | + socks4_config = Configuration( |
| 57 | + server_url="https://play.orkes.io/api", |
| 58 | + proxy="socks4://proxy.company.com:1080" |
| 59 | + ) |
| 60 | + |
| 61 | + # Usage: |
| 62 | + |
| 63 | + # Create API client with proxy configuration |
| 64 | + async with ApiClient(config) as api_client: |
| 65 | + # Create OrkesClients with the API client |
| 66 | + orkes_clients = OrkesClients(api_client, config) |
| 67 | + workflow_client = orkes_clients.get_workflow_client() |
| 68 | + |
| 69 | + # Example: Get workflow definitions (this will go through the proxy) |
| 70 | + # Note: This will only work if you have valid credentials and the proxy is accessible |
| 71 | + |
| 72 | + workflows = await workflow_client.search_workflows() |
| 73 | + print(f"Found {len(workflows)} workflows") |
| 74 | + |
| 75 | + |
| 76 | +if __name__ == "__main__": |
| 77 | + asyncio.run(main()) |
0 commit comments