(cls, key: str | ApiProvider)
| 15 | |
| 16 | @classmethod |
| 17 | def get_api_key(cls, key: str | ApiProvider): |
| 18 | if isinstance(key, ApiProvider): |
| 19 | key = key.value |
| 20 | |
| 21 | # Check if the key is present in the database |
| 22 | api_key = cls.api_key_doc_manager._get(key) |
| 23 | if api_key: |
| 24 | return api_key |
| 25 | |
| 26 | # If not found in the database, check in the environment variables |
| 27 | env_key = key.replace(" ", "_").upper() |
| 28 | api_key = os.environ.get(env_key) |
| 29 | if api_key: |
| 30 | return api_key |
| 31 | |
| 32 | return "" |
| 33 | |
| 34 | @classmethod |
| 35 | def set_api_key(cls, key: str | ApiProvider, value: str): |
no test coverage detected