orionapi 2.28.0__tar.gz → 2.29.0__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionapi
3
- Version: 2.28.0
3
+ Version: 2.29.0
4
4
  Summary: A python interface for the Orion Advisors platform web API
5
5
  Author: spencerogden-dsam
6
6
  Author-email: 67068943+spencerogden-dsam@users.noreply.github.com
@@ -1,4 +1,4 @@
1
- __version__ = "2.28.0"
1
+ __version__ = "2.29.0"
2
2
 
3
3
  import logging
4
4
  import re
@@ -332,6 +332,25 @@ class BaseAPI:
332
332
 
333
333
  return data
334
334
 
335
+ def _request_kwargs(self, timeout=None):
336
+ """Timeout + SSL kwargs for unauthenticated (pre-token) requests.
337
+
338
+ ``login()`` cannot go through :meth:`api_request` — there is no token yet,
339
+ so header construction would raise — but it still needs the same timeout
340
+ and SSL defaults applied here.
341
+
342
+ Args:
343
+ timeout: Per-call timeout in seconds. When None, falls back to the
344
+ client's ``self.timeout``.
345
+
346
+ Returns:
347
+ dict: ``timeout`` and ``verify`` kwargs for ``requests``.
348
+ """
349
+ return {
350
+ "timeout": self.timeout if timeout is None else timeout,
351
+ "verify": self.ca_bundle if self.ca_bundle else self.verify_ssl,
352
+ }
353
+
335
354
  def api_request(self, url, req_func=None, timeout=None, **kwargs):
336
355
  """Make an authenticated API request with error handling.
337
356
 
@@ -440,18 +459,24 @@ class OrionAPI(BaseAPI):
440
459
  self.login(usr, pwd)
441
460
  # Credentials are not stored to prevent memory exposure
442
461
 
443
- def login(self, usr=None, pwd=None):
462
+ def login(self, usr=None, pwd=None, timeout=None):
444
463
  """Authenticate with the Orion API.
445
464
 
446
465
  Args:
447
466
  usr: Username for authentication
448
467
  pwd: Password for authentication
468
+ timeout: Request timeout in seconds. When None (default), falls back
469
+ to the client's ``self.timeout`` (constructor default 30).
449
470
 
450
471
  Raises:
451
472
  AuthenticationError: If credentials are invalid
452
473
  """
453
474
  with self._token_lock:
454
- res = requests.get(f"{self.base_url}/security/token", auth=(usr, pwd))
475
+ res = requests.get(
476
+ f"{self.base_url}/security/token",
477
+ auth=(usr, pwd),
478
+ **self._request_kwargs(timeout),
479
+ )
455
480
  if not res.ok:
456
481
  raise AuthenticationError(f"Login failed: {res.status_code} {res.reason}")
457
482
  try:
@@ -2275,13 +2300,15 @@ class EclipseBase(BaseAPI):
2275
2300
  elif orion_token is not None:
2276
2301
  self.login(orion_token=orion_token)
2277
2302
 
2278
- def login(self, usr=None, pwd=None, orion_token=None):
2303
+ def login(self, usr=None, pwd=None, orion_token=None, timeout=None):
2279
2304
  """Authenticate with the Eclipse API.
2280
2305
 
2281
2306
  Args:
2282
2307
  usr: Username for authentication
2283
2308
  pwd: Password for authentication
2284
2309
  orion_token: Orion session token (alternative to usr/pwd)
2310
+ timeout: Request timeout in seconds. When None (default), falls back
2311
+ to the client's ``self.timeout`` (constructor default 30).
2285
2312
 
2286
2313
  Raises:
2287
2314
  AuthenticationError: If credentials are invalid or missing
@@ -2291,7 +2318,11 @@ class EclipseBase(BaseAPI):
2291
2318
 
2292
2319
  with self._token_lock:
2293
2320
  if usr is not None:
2294
- res = requests.get(f"{self.base_url}/admin/token", auth=(usr, pwd))
2321
+ res = requests.get(
2322
+ f"{self.base_url}/admin/token",
2323
+ auth=(usr, pwd),
2324
+ **self._request_kwargs(timeout),
2325
+ )
2295
2326
  if not res.ok:
2296
2327
  raise AuthenticationError(f"Login failed: {res.status_code} {res.reason}")
2297
2328
  try:
@@ -2303,6 +2334,7 @@ class EclipseBase(BaseAPI):
2303
2334
  res = requests.get(
2304
2335
  f"{self.base_url}/admin/token",
2305
2336
  headers={"Authorization": "Session " + orion_token},
2337
+ **self._request_kwargs(timeout),
2306
2338
  )
2307
2339
  if not res.ok:
2308
2340
  raise AuthenticationError(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "orionapi"
3
- version = "2.28.0"
3
+ version = "2.29.0"
4
4
  description = "A python interface for the Orion Advisors platform web API"
5
5
  authors = ["spencerogden-dsam <67068943+spencerogden-dsam@users.noreply.github.com>"]
6
6
 
File without changes