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