Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 24056a7

Browse files
authored
Alpha10 (#152)
* Update docstring for behavior * Refactor how credentials are applied, fixes #151 * Bump version
1 parent 49a207d commit 24056a7

5 files changed

Lines changed: 10 additions & 13 deletions

File tree

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# History
22

3+
## 2.0.0-alpha10 (2020-04-09)
4+
5+
- Refactor how and where credentials are applied to request headers (#151)
6+
37
## 2.0.0-alpha9 (2020-04-04)
48

59
- Now checking if static `access_token` exists before attempting a developer token refresh (#147)

pan_cortex_data_lake/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Main package for cortex."""
44

55
__author__ = "Palo Alto Networks"
6-
__version__ = "2.0.0-a9"
6+
__version__ = "2.0.0-a10"
77

88
from .exceptions import ( # noqa: F401
99
CortexError,

pan_cortex_data_lake/httpclient.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, **kwargs):
4545
granular performance and reliability tuning.
4646
4747
Parameters:
48-
auto_refresh (bool): Perform token refresh following HTTP 401 response from server. Defaults to ``True``.
48+
auto_refresh (bool): Perform token refresh prior to request if ``access_token`` is ``None`` or expired. Defaults to ``True``.
4949
auto_retry (bool): Retry last failed HTTP request following a token refresh. Defaults to ``True``.
5050
credentials (Credentials): :class:`~pan_cortex_data_lake.credentials.Credentials` object. Defaults to ``None``.
5151
enforce_json (bool): Require properly-formatted JSON or raise :exc:`~pan_cortex_data_lake.exceptions.CortecError`. Defaults to ``False``.
@@ -94,13 +94,6 @@ def __init__(self, **kwargs):
9494
if len(kwargs) > 0: # Handle invalid kwargs
9595
raise UnexpectedKwargsError(kwargs)
9696

97-
if self.credentials:
98-
logger.debug("Applying session-level credentials")
99-
self._apply_credentials(
100-
auto_refresh=self.auto_refresh,
101-
credentials=self.credentials,
102-
headers=self.session.headers,
103-
)
10497
self.stats = ApiStats({"transactions": 0})
10598

10699
def __repr__(self):
@@ -139,7 +132,7 @@ def _apply_credentials(auto_refresh=True, credentials=None, headers=None):
139132
if token is None:
140133
token = credentials.refresh(access_token=None, timeout=10)
141134
logger.debug("Token refreshed due to 'None' condition")
142-
elif credentials.jwt_is_expired():
135+
elif credentials.jwt_is_expired(token):
143136
token = credentials.refresh(timeout=10)
144137
logger.debug("Token refreshed due to 'expired' condition")
145138
headers.update({"Authorization": "Bearer {}".format(token)})
@@ -220,7 +213,7 @@ def request(self, **kwargs):
220213

221214
# Non-Requests key-word arguments
222215
auto_refresh = kwargs.pop("auto_refresh", self.auto_refresh)
223-
credentials = kwargs.pop("credentials", None)
216+
credentials = kwargs.pop("credentials", self.credentials)
224217
endpoint = kwargs.pop("endpoint", "") # default to empty endpoint
225218
enforce_json = kwargs.pop("enforce_json", self.enforce_json)
226219
raise_for_status = kwargs.pop("raise_for_status", self.raise_for_status)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.0.0a9
2+
current_version = 2.0.0a10
33
commit = True
44
tag = True
55

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
setup(
2424
name="pan-cortex-data-lake",
25-
version="2.0.0-a9",
25+
version="2.0.0-a10",
2626
description="Python idiomatic SDK for Cortex™ Data Lake.",
2727
long_description=readme + "\n\n" + history,
2828
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)