11from __future__ import annotations
22
3+ import json
34import logging
45import os
56from typing import Any , Dict , Optional , Union
@@ -94,8 +95,20 @@ def __init__(
9495 Default polling interval for workers in seconds.
9596 default_domain : str, optional
9697 Default domain for workers.
98+ proxy : str, optional
99+ Proxy URL for HTTP requests. If not provided, reads from CONDUCTOR_PROXY env var.
100+ proxy_headers : Dict[str, str], optional
101+ Headers to send with proxy requests. If not provided, reads from CONDUCTOR_PROXY_HEADERS env var.
97102 **kwargs : Any
98103 Additional parameters passed to HttpConfiguration.
104+
105+ Environment Variables:
106+ ---------------------
107+ CONDUCTOR_SERVER_URL: Server URL (e.g., http://localhost:8080/api)
108+ CONDUCTOR_AUTH_KEY: Authentication key ID
109+ CONDUCTOR_AUTH_SECRET: Authentication key secret
110+ CONDUCTOR_PROXY: Proxy URL for HTTP requests
111+ CONDUCTOR_PROXY_HEADERS: Proxy headers as JSON string or single header value
99112 """
100113
101114 # Resolve server URL from parameter or environment variable
@@ -139,8 +152,18 @@ def __init__(
139152 if self .__ui_host is None :
140153 self .__ui_host = self .server_url .replace ("/api" , "" )
141154
142- self .proxy = proxy
155+ # Proxy configuration - can be set via parameter or environment variable
156+ self .proxy = proxy or os .getenv ("CONDUCTOR_PROXY" )
157+ # Proxy headers - can be set via parameter or environment variable
143158 self .proxy_headers = proxy_headers
159+ if not self .proxy_headers and os .getenv ("CONDUCTOR_PROXY_HEADERS" ):
160+ try :
161+ self .proxy_headers = json .loads (os .getenv ("CONDUCTOR_PROXY_HEADERS" ))
162+ except (json .JSONDecodeError , TypeError ):
163+ # If JSON parsing fails, treat as a single header value
164+ self .proxy_headers = {
165+ "Authorization" : os .getenv ("CONDUCTOR_PROXY_HEADERS" )
166+ }
144167
145168 self .logger_format = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s"
146169
@@ -164,6 +187,12 @@ def __init__(
164187 ** kwargs ,
165188 )
166189
190+ # Set proxy configuration on the HTTP config
191+ if self .proxy :
192+ self ._http_config .proxy = self .proxy
193+ if self .proxy_headers :
194+ self ._http_config .proxy_headers = self .proxy_headers
195+
167196 # Debug switch and logging setup
168197 self .__debug = debug
169198 if self .__debug :
0 commit comments