Skip to content

Commit 00c275e

Browse files
Added examples with proxy configuration
1 parent fbe45a0 commit 00c275e

2 files changed

Lines changed: 155 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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())

examples/sync_proxy_example.py

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

0 commit comments

Comments
 (0)