Skip to content

Commit 2e38a3b

Browse files
authored
Merge pull request #18 from jplacht/feat-config
Add configuration file solution
2 parents cf55b95 + 9414f67 commit 2e38a3b

34 files changed

+659
-272
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ omit =
77
tests/*
88
# omit abstract endpoints
99
*/abstracts/*
10+
# omit config due to base_config
11+
*/config.py

docs/config.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Config
2+
3+
FIO Wrapper internally uses a configuration file to provide its standard capabilities. The configuration can be [overwritten](usage.md) by the user.
4+
5+
6+
7+
## `base.ini`
8+
9+
```ini
10+
[FIO]
11+
application = FIO Wrapper
12+
version = 1.0.0
13+
base_url = https://rest.fnar.net
14+
timeout = 10
15+
ssl_verify = True
16+
versions = 1.0.0
17+
18+
[URL]
19+
# material
20+
1.0.0_material_base = /material
21+
1.0.0_material_all = /allmaterials
22+
23+
# exchange
24+
1.0.0_exchange_base = /exchange
25+
1.0.0_exchange_orders = /orders
26+
1.0.0_exchange_all = /all
27+
1.0.0_exchange_full = /full
28+
29+
# building
30+
1.0.0_building_base = /building
31+
1.0.0_building_all = /allbuildings
32+
33+
# recipe
34+
1.0.0_recipe_base = /recipes
35+
1.0.0_recipe_all = /allrecipes
36+
37+
# planet
38+
1.0.0_planet_base = /planet
39+
1.0.0_planet_all = /allplanets
40+
1.0.0_planet_full = /allplanets/full
41+
1.0.0_planet_sites = /sites
42+
1.0.0_planet_search = /search
43+
44+
# localmarket
45+
1.0.0_localmarket_base = /localmarket
46+
1.0.0_localmarket_planet = /planet
47+
1.0.0_localmarket_shipping_source = /shipping/source
48+
1.0.0_localmarket_shipping_destination = /shipping/destination
49+
1.0.0_localmarket_company = /company
50+
51+
# sites
52+
1.0.0_sites_base = /sites
53+
1.0.0_sites_planets = /planets
54+
1.0.0_sites_warehouses = /warehouses
55+
56+
# storage
57+
1.0.0_storage_base = /storage
58+
1.0.0_storage_planets = /planets
59+
60+
# groups
61+
1.0.0_groups = /auth/groups
62+
1.0.0_groups_group = /auth/group
63+
1.0.0_groups_groupmemberships = /auth/groupmemberships
64+
1.0.0_groups_hub = /fioweb/grouphub
65+
1.0.0_groups_burn = /fioweb/burn/group
66+
```
67+
68+
## Config() class
69+
::: config

docs/timeouts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ fio = FIO(timeout=5)
2323

2424
FIO Wrapper will now apply the timeout of `5 seconds` to all calls it is making towards FIO.
2525

26+
## Configuration file
27+
28+
A standard timeout can also be defined in a users [configuration file](config.md).
29+
2630
## Indidivual endpoint calls
2731

2832
All endpoints allow passing the optional `timeout` argument that is of type `Optional[float]` and defaults to `None`.

docs/usage.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# Installation
1+
# Usage
2+
## Installation
23
```python
34
pip install fio-wrapper
45
```
56

6-
# Usage
7+
## Simple Usage
78
Creating the FIO adapter and looking for information about the material Drinking Water by its ticker "DW".
89
```python
910
from fio_wrapper import FIO
@@ -30,3 +31,36 @@ This will print the material information of Drinking Water as MaterialModel and
3031
"Timestamp": "2023-10-28T19:26:21.831707"
3132
}
3233
```
34+
35+
## Additional parameters
36+
37+
FIO Wrapper allows you to specify additional attributes when instantiating. The most commonly used is `api_key` that lets you add your FIO API Key (obtained on the [FIO Website](https://fio.fnar.net/settings)) to access protected endpoints like [Site](endpoints/sites.md) or [Storage](endpoints/storage.md).
38+
39+
```python
40+
from fio_wrapper import FIO
41+
42+
fio = FIO(api_key="YOUR_FIO_API_KEY")
43+
```
44+
45+
The complete list of parameters can be found on [`FIO()`](fio.md).
46+
47+
## Configuration file
48+
49+
FIO Wrapper can use a configuration file provided upon instantiation to overwrite its [base configuration](config.md).
50+
51+
Example configuration file `config.ini`:
52+
53+
```ini
54+
[FIO]
55+
application = My Awesome FIO application
56+
timeout = 3
57+
api_key = MY_FIO_API_KEY
58+
```
59+
60+
Use this configuration file on [`FIO()`](fio.md) by providing the `config` attribute:
61+
62+
```python
63+
from fio_wrapper import FIO
64+
65+
fio = FIO(config="config.ini")
66+
```

fio_wrapper/base.ini

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[FIO]
2+
application = FIO Wrapper
3+
version = 1.0.0
4+
base_url = https://rest.fnar.net
5+
timeout = 10
6+
ssl_verify = True
7+
versions = 1.0.0
8+
9+
[URL]
10+
# material
11+
1.0.0_material_base = /material
12+
1.0.0_material_all = /allmaterials
13+
14+
# exchange
15+
1.0.0_exchange_base = /exchange
16+
1.0.0_exchange_orders = /orders
17+
1.0.0_exchange_all = /all
18+
1.0.0_exchange_full = /full
19+
20+
# building
21+
1.0.0_building_base = /building
22+
1.0.0_building_all = /allbuildings
23+
24+
# recipe
25+
1.0.0_recipe_base = /recipes
26+
1.0.0_recipe_all = /allrecipes
27+
28+
# planet
29+
1.0.0_planet_base = /planet
30+
1.0.0_planet_all = /allplanets
31+
1.0.0_planet_full = /allplanets/full
32+
1.0.0_planet_sites = /sites
33+
1.0.0_planet_search = /search
34+
35+
# localmarket
36+
1.0.0_localmarket_base = /localmarket
37+
1.0.0_localmarket_planet = /planet
38+
1.0.0_localmarket_shipping_source = /shipping/source
39+
1.0.0_localmarket_shipping_destination = /shipping/destination
40+
1.0.0_localmarket_company = /company
41+
42+
# sites
43+
1.0.0_sites_base = /sites
44+
1.0.0_sites_planets = /planets
45+
1.0.0_sites_warehouses = /warehouses
46+
47+
# storage
48+
1.0.0_storage_base = /storage
49+
1.0.0_storage_planets = /planets
50+
51+
# groups
52+
1.0.0_groups = /auth/groups
53+
1.0.0_groups_group = /auth/group
54+
1.0.0_groups_groupmemberships = /auth/groupmemberships
55+
1.0.0_groups_hub = /fioweb/grouphub
56+
1.0.0_groups_burn = /fioweb/burn/group

0 commit comments

Comments
 (0)