Standard Client
Usage
Overview
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | from config import ConfigClient
cc = ConfigClient(app_name='foo', label='main')
cc.get_config()
# option 1: dict like with direct access
cc.config['spring']['cloud']['config']['uri']
# option 2: dict like using get
cc.config.get('spring').get('cloud').get('config').get('uri')
# option 3: using get
cc.get('spring.cloud.config.uri')
|
Custom parameters on HTTP request
| from config import ConfigClient
cc = ConfigClient(app_name='foo', label='main')
cc.get_config(timeout=5.0, headers={'Accept': 'application/json'})
|
Any parameter supported by the get
method from the requests library can be used on get_config
, including: authentication, SSL verification or custom headers.
Details:
Authentication
OAuth2
1
2
3
4
5
6
7
8
9
10
11
12
13 | from config import ConfigClient
from config.auth import OAuth2
cc = ConfigClient(
app_name='foo',
label='main',
oauth2=OAuth2(
access_token_uri='http://srv/token',
client_id='my_client_id',
client_secret='client_credentials'
)
)
cc.get_config()
|
Basic
| from requests.auth import HTTPBasicAuth
from config import ConfigClient
cc = ConfigClient(app_name='foo', label='main')
cc.get_config(auth=HTTPBasicAuth('user', 'passwd'))
|
Digest
| from requests.auth import HTTPDigestAuth
from config import ConfigClient
cc = ConfigClient(app_name='foo', label='main')
cc.get_config(auth=HTTPDigestAuth('user', 'passwd'))
|
Retrieving plain files
| from config import ConfigClient
cc = ConfigClient(app_name='foo', label='main')
cc.get_file('books.xml')
|