We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54a1cc0 commit 2b88080Copy full SHA for 2b88080
flareio/api_client.py
@@ -1,3 +1,4 @@
1
+import os
2
import requests
3
4
from datetime import datetime
@@ -31,6 +32,17 @@ def __init__(
31
32
self._api_token_exp: t.Optional[datetime] = None
33
self._session = session or self._create_session()
34
35
+ @classmethod
36
+ def from_env(cls) -> "FlareApiClient":
37
+ api_key: t.Optional[str] = os.environ.get("FLARE_API_KEY")
38
+ if not api_key:
39
+ raise Exception("Please set the FLARE_API_KEY environment variable")
40
+ tenant_id: t.Optional[str] = os.environ.get("FLARE_TENANT_ID")
41
+ return cls(
42
+ api_key=api_key,
43
+ tenant_id=int(tenant_id) if tenant_id is not None else None,
44
+ )
45
+
46
@staticmethod
47
def _create_session() -> requests.Session:
48
session = requests.Session()
0 commit comments