orionapi 2.32.0__tar.gz → 2.32.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = "2.32.
|
|
1
|
+
__version__ = "2.32.1"
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import re
|
|
@@ -2716,6 +2716,9 @@ class EclipseBase(BaseAPI):
|
|
|
2716
2716
|
super().__init__(
|
|
2717
2717
|
rate_limit=rate_limit, verify_ssl=verify_ssl, ca_bundle=ca_bundle, timeout=timeout
|
|
2718
2718
|
)
|
|
2719
|
+
# Auth state (token, lock) lives on the owner: this client, or the
|
|
2720
|
+
# Eclipse unifier that composes it (see Eclipse._adopt).
|
|
2721
|
+
self._auth_owner = self
|
|
2719
2722
|
self.eclipse_token = None
|
|
2720
2723
|
self.base_url = "https://api.orioneclipse.com/v1"
|
|
2721
2724
|
# The v2 surface lives at the host root (/api/v2/...), NOT under /v1.
|
|
@@ -2732,9 +2735,22 @@ class EclipseBase(BaseAPI):
|
|
|
2732
2735
|
elif orion_token is not None:
|
|
2733
2736
|
self.login(orion_token=orion_token)
|
|
2734
2737
|
|
|
2738
|
+
@property
|
|
2739
|
+
def eclipse_token(self):
|
|
2740
|
+
"""The Eclipse session token, shared with the owning Eclipse unifier."""
|
|
2741
|
+
return self._auth_owner.__dict__.get("_eclipse_token")
|
|
2742
|
+
|
|
2743
|
+
@eclipse_token.setter
|
|
2744
|
+
def eclipse_token(self, value):
|
|
2745
|
+
self._auth_owner.__dict__["_eclipse_token"] = value
|
|
2746
|
+
|
|
2735
2747
|
def login(self, usr=None, pwd=None, orion_token=None, timeout=None):
|
|
2736
2748
|
"""Authenticate with the Eclipse API.
|
|
2737
2749
|
|
|
2750
|
+
On an Eclipse unifier (or its ``.v1`` / ``.v2``), the new token is
|
|
2751
|
+
shared by all three. The library does not keep credentials, so after
|
|
2752
|
+
a session expires the caller must call login() again.
|
|
2753
|
+
|
|
2738
2754
|
Args:
|
|
2739
2755
|
usr: Username for authentication
|
|
2740
2756
|
pwd: Password for authentication
|
|
@@ -2976,7 +2992,8 @@ class EclipseBase(BaseAPI):
|
|
|
2976
2992
|
OrionAPIError: if the user has no firm id or more than one (pass
|
|
2977
2993
|
``orionConnectFirmId`` explicitly in that case)
|
|
2978
2994
|
"""
|
|
2979
|
-
|
|
2995
|
+
owner = self._auth_owner # cache once per unifier, not per sub-client
|
|
2996
|
+
if getattr(owner, "_orion_connect_firm_id", None) is None:
|
|
2980
2997
|
res = self.api_request(f"{self.base_url}/admin/authorization/user")
|
|
2981
2998
|
firm_ids = res.json().get("ocFirmId") or []
|
|
2982
2999
|
if len(firm_ids) != 1:
|
|
@@ -2984,8 +3001,8 @@ class EclipseBase(BaseAPI):
|
|
|
2984
3001
|
f"Expected one Orion Connect firm id for this user, got {firm_ids!r}; "
|
|
2985
3002
|
"pass orionConnectFirmId explicitly"
|
|
2986
3003
|
)
|
|
2987
|
-
|
|
2988
|
-
return
|
|
3004
|
+
owner._orion_connect_firm_id = firm_ids[0]
|
|
3005
|
+
return owner._orion_connect_firm_id
|
|
2989
3006
|
|
|
2990
3007
|
|
|
2991
3008
|
class EclipseV1(EclipseBase):
|
|
@@ -12319,16 +12336,19 @@ class Eclipse(EclipseBase):
|
|
|
12319
12336
|
ca_bundle=ca_bundle,
|
|
12320
12337
|
timeout=timeout,
|
|
12321
12338
|
)
|
|
12322
|
-
#
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12339
|
+
# Sub-clients share this client's auth state and rate limiter, so a
|
|
12340
|
+
# later login() (or token assignment) reaches .v1 / .v2 too, and the
|
|
12341
|
+
# rate limit applies to the unifier as a whole.
|
|
12342
|
+
sub_kwargs = {"verify_ssl": verify_ssl, "ca_bundle": ca_bundle, "timeout": timeout}
|
|
12343
|
+
self.v1 = self._adopt(EclipseV1(**sub_kwargs))
|
|
12344
|
+
self.v2 = self._adopt(EclipseV2(**sub_kwargs))
|
|
12345
|
+
|
|
12346
|
+
def _adopt(self, client):
|
|
12347
|
+
"""Point a sub-client's token, lock and rate limiter at this client."""
|
|
12348
|
+
client._auth_owner = self
|
|
12349
|
+
client._token_lock = self._token_lock
|
|
12350
|
+
client._rate_limiter = self._rate_limiter
|
|
12351
|
+
return client
|
|
12332
12352
|
|
|
12333
12353
|
def __getattr__(self, name):
|
|
12334
12354
|
"""Delegate unknown attributes to the v1 surface, then the v2 surface.
|
|
File without changes
|