Skip to content

Commit 6fdd78a

Browse files
authored
fix: set proxy server in config file (#283)
1 parent 2a0bd82 commit 6fdd78a

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Features
44
1. [#281](https://github.com/influxdata/influxdb-client-python/pull/281): `FluxTable`, `FluxColumn` and `FluxRecord` objects have helpful reprs
55

6+
### Bug Fixes
7+
1. [#283](https://github.com/influxdata/influxdb-client-python/pull/283): Set proxy server in config file
8+
69
## 1.19.0 [2021-07-09]
710

811
### Features

influxdb_client/client/influxdb_client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz
115115
- connection_pool_maxsize
116116
- auth_basic
117117
- profilers
118+
- proxy
118119
119120
120121
config.ini example::
@@ -127,6 +128,7 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz
127128
connection_pool_maxsize=25
128129
auth_basic=false
129130
profilers=query,operator
131+
proxy=http:proxy.domain.org:8080
130132
131133
[tags]
132134
id = 132-987-655
@@ -143,6 +145,7 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz
143145
connection_pool_maxsize = 25
144146
auth_basic = false
145147
profilers="query, operator"
148+
proxy = "http://proxy.domain.org:8080"
146149
147150
[tags]
148151
id = "132-987-655"
@@ -192,10 +195,14 @@ def config_value(key: str):
192195
if config.has_option('influx2', 'profilers'):
193196
profilers = [x.strip() for x in config_value('profilers').split(',')]
194197

198+
proxy = None
199+
if config.has_option('influx2', 'proxy'):
200+
proxy = config_value('proxy')
201+
195202
return cls(url, token, debug=debug, timeout=_to_int(timeout), org=org, default_tags=default_tags,
196203
enable_gzip=enable_gzip, verify_ssl=_to_bool(verify_ssl), ssl_ca_cert=ssl_ca_cert,
197204
connection_pool_maxsize=_to_int(connection_pool_maxsize), auth_basic=_to_bool(auth_basic),
198-
profilers=profilers)
205+
profilers=profilers, proxy=proxy)
199206

200207
@classmethod
201208
def from_env_properties(cls, debug=None, enable_gzip=False):

tests/config-enabled-proxy.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[influx2]
2+
url=http://localhost:8086
3+
org=my-org
4+
token=my-token
5+
timeout=6000
6+
connection_pool_maxsize=55
7+
auth_basic=false
8+
profilers=query, operator
9+
proxy=http://proxy.domain.org:8080
10+
11+
[tags]
12+
id = 132-987-655
13+
customer = California Miner
14+
data_center = ${env.data_center}

tests/test_InfluxDBClient.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def assertConfig(self):
7575
self.assertEqual(False, self.client.api_client.configuration.auth_basic)
7676
self.assertEqual(["query", "operator"], self.client.profilers)
7777

78+
def test_init_from_file_proxy(self):
79+
self.client = InfluxDBClient.from_config_file(f'{os.path.dirname(__file__)}/config-enabled-proxy.ini')
80+
self.assertConfig()
81+
self.assertEqual("http://proxy.domain.org:8080", self.client.api_client.configuration.proxy)
82+
7883
def test_init_from_file_ssl_default(self):
7984
self.client = InfluxDBClient.from_config_file(f'{os.path.dirname(__file__)}/config.ini')
8085

0 commit comments

Comments
 (0)