-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
76 lines (56 loc) · 1.9 KB
/
Copy pathconfig.py
File metadata and controls
76 lines (56 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Configuration module for INSEE API.
This module handles all configuration including API endpoints,
credentials and environment variables.
"""
import os
from typing import Optional
class Config:
"""Central configuration for all API clients."""
# INSEE API Token
INSEE_API_TOKEN: Optional[str] = os.getenv("INSEE_API_TOKEN")
# INSEE API Configuration
INSEE_API_BASE: str = "https://api.insee.fr"
# INSEE API Sirene Configuration
INSEE_API_SIRENE: str = f"{INSEE_API_BASE}/api-sirene/3.11"
# INSEE API Données locales Configuration
INSEE_API_DONNEES_LOCALES: str = f"{INSEE_API_BASE}/donnees-locales"
# INSEE Metadata API Configuration
INSEE_METADATA_API: str = f"{INSEE_API_BASE}/metadonnees"
# INSEE API Melodi
INSEE_API_MELODI: str = f"{INSEE_API_BASE}/melodi"
# INSEE API Séries chronologiques
INSEE_API_SERIES_CHRONOLOGIQUES: str = f"{INSEE_API_BASE}/series/BDM"
# OTHER INSEE API Endpoints
GEO_BASE_V1: str = "https://api.insee.fr/metadonnees/V1/geo"
# Request Configuration
DEFAULT_TIMEOUT: int = 30 # seconds
MAX_RETRIES: int = 3
@classmethod
def get_insee_token(cls) -> str:
"""
Get INSEE API token from environment.
Returns:
str:
INSEE API token.
Raises:
ValueError:
If no token is available.
"""
token = cls.INSEE_API_TOKEN
if not token:
raise ValueError(
"INSEE API token not found. Please set the INSEE_API_TOKEN environment variable."
)
return token
@classmethod
def validate_configuration(cls) -> dict:
"""
Validate configuration and return status.
Returns:
dict:
Configuration validation status.
"""
return {
"insee_token_configured": bool(cls.INSEE_API_TOKEN),
}