Skip to content

Commit 3691bc9

Browse files
committed
Allow to configure the base domain (defaults to armis.com)
1 parent 8ef8308 commit 3691bc9

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

armis_sdk/core/armis_client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
from armis_sdk.core import response_utils
1414
from armis_sdk.core.armis_auth import ArmisAuth
1515

16+
ARMIS_BASE_DOMAIN = "ARMIS_BASE_DOMAIN"
17+
ARMIS_CLIENT_ID = "ARMIS_CLIENT_ID"
1618
ARMIS_PAGE_SIZE = "ARMIS_PAGE_SIZE"
1719
ARMIS_REQUEST_RETRIES = "ARMIS_REQUEST_RETRIES"
1820
ARMIS_SECRET_KEY = "ARMIS_SECRET_KEY"
1921
ARMIS_TENANT = "ARMIS_TENANT"
20-
ARMIS_CLIENT_ID = "ARMIS_CLIENT_ID"
21-
BASE_URL = "https://{tenant}.armis.com"
22+
BASE_DOMAIN = "armis.com"
23+
BASE_URL = "https://{tenant}.{base_domain}"
2224
DEFAULT_PAGE_LENGTH = 1000
2325
try:
2426
VERSION = importlib.metadata.version("armis_sdk")
@@ -48,10 +50,12 @@ def __init__(
4850
tenant: Optional[str] = None,
4951
secret_key: Optional[str] = None,
5052
client_id: Optional[str] = None,
53+
base_domain: Optional[str] = BASE_DOMAIN,
5154
):
5255
tenant = os.getenv(ARMIS_TENANT, tenant)
5356
secret_key = os.getenv(ARMIS_SECRET_KEY, secret_key)
5457
client_id = os.getenv(ARMIS_CLIENT_ID, client_id)
58+
base_domain = os.getenv(ARMIS_BASE_DOMAIN, base_domain)
5559

5660
if not tenant:
5761
raise ValueError(
@@ -69,7 +73,7 @@ def __init__(
6973
f"or pass an explicit value to the constructor"
7074
)
7175

72-
self._base_url = BASE_URL.format(tenant=tenant)
76+
self._base_url = BASE_URL.format(tenant=tenant, base_domain=base_domain)
7377
self._auth = ArmisAuth(self._base_url, secret_key)
7478
self._user_agent = " ".join(USER_AGENT_PARTS)
7579
self._client_id = client_id

armis_sdk/core/armis_sdk.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from armis_sdk.clients.sites_client import SitesClient
44
from armis_sdk.core.armis_client import ArmisClient
5+
from armis_sdk.core import armis_client
56

67
ARMIS_SECRET_KEY = "ARMIS_SECRET_KEY"
78
ARMIS_TENANT = "ARMIS_TENANT"
@@ -39,8 +40,12 @@ def __init__(
3940
tenant: Optional[str] = None,
4041
secret_key: Optional[str] = None,
4142
client_id: Optional[str] = None,
43+
base_domain: Optional[str] = armis_client.BASE_DOMAIN,
4244
):
4345
self.client = ArmisClient(
44-
tenant=tenant, client_id=client_id, secret_key=secret_key
46+
tenant=tenant,
47+
client_id=client_id,
48+
secret_key=secret_key,
49+
base_domain=base_domain,
4550
)
4651
self.sites = SitesClient(self.client)

docs/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ pip install armis_sdk
99
```
1010
## Usage
1111

12-
All interaction with the SDK happens through the [ArmisSdk][armis_sdk.core.armis_sdk.ArmisSdk] class. You'll need 3 things:
12+
All interaction with the SDK happens through the [ArmisSdk][armis_sdk.core.armis_sdk.ArmisSdk] class. You'll need a few things:
1313

1414
1. **Tenant name**: The name of the tenant you want to interact with.
1515
2. **Secret key**: The secret key associated with the tenant, obtained from the tenant itself.
1616
3. **Client id**: A unique identifier for you application. Currently, this can be any string.
17+
4. **(optional) Base domain**: The base domain of you tenant, defaults to `armis.com`,
1718

18-
You can either provide these values using the environment variables `ARMIS_TENANT`, `ARMIS_SECRET_KEY`, and `ARMIS_CLIENT_ID`:
19+
You can either provide these values using the environment variables `ARMIS_TENANT`, `ARMIS_SECRET_KEY`, `ARMIS_CLIENT_ID`, and `ARMIS_BASE_DOMAIN`:
1920
```python linenums="1"
2021
from armis_sdk import ArmisSdk
2122

@@ -26,7 +27,7 @@ or by passing them explicitly:
2627
```python linenums="1"
2728
from armis_sdk import ArmisSdk
2829

29-
armis_sdk = ArmisSdk(tenant="<tenant>", secret_key="<secret_key>", client_id="<client_id>")
30+
armis_sdk = ArmisSdk(tenant="<tenant>", secret_key="<secret_key>", client_id="<client_id>", base_domain="<base_domain>")
3031
```
3132
!!!tip
3233

0 commit comments

Comments
 (0)