Coverage for mlair/configuration/join_settings.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2023-06-30 10:22 +0000

1"""Settings to access not public join data.""" 

2from typing import Tuple, Dict 

3 

4 

5def join_settings(sampling="daily") -> Tuple[str, Dict]: 

6 """ 

7 Set url for join and required headers. 

8 

9 Headers information is not required for daily resolution. For hourly data "Authorization": "<yourtoken>" is required 

10 to retrieve any data at all. 

11 

12 :param sampling: temporal resolution to access. Hourly data requires authorisation. 

13 

14 :return: Service url and optional headers 

15 """ 

16 if sampling == "daily": # pragma: no branch 

17 TOAR_SERVICE_URL = 'https://join.fz-juelich.de/services/rest/surfacedata/' 

18 headers = {} 

19 elif sampling == "hourly": 

20 TOAR_SERVICE_URL = 'https://join.fz-juelich.de/services/rest/surfacedata/' 

21 headers = {"Authorization": "Token 12345"} 

22 else: 

23 raise NameError(f"Given sampling {sampling} is not supported, choose from either daily or hourly sampling.") 

24 return TOAR_SERVICE_URL, headers