Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit d3709b3

Browse files
authored
Alpha9 (#150)
* Update clientType and clientVersion, fixes #149 * Reduce number of times json() property is called, fixes #148 * Check if static access_token exists before developer token refresh, fixes #147 * Bump version to alpha9
1 parent 754b589 commit d3709b3

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

HISTORY.md

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

3+
## 2.0.0-alpha9 (2020-04-04)
4+
5+
- Now checking if static `access_token` exists before attempting a developer token refresh (#147)
6+
- Reduced the number of times `json()` property is called in `QueryService` and `HTTPClient` (#148)
7+
- Updated `clientType` and `clientVersion` in `create_query()` method (#149)
8+
- Updated `iter_job_results()` to use `pageCursor` instead of deprecated `scrollToken` (#145)
9+
- Switched to using `rowsInPage` instead of `rowsInJob` when updating `stats.records` in `get_job_results()` (#146)
10+
311
## 2.0.0-alpha8 (2020-03-25)
412

513
- Updated docstrings

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-a8"
6+
__version__ = "2.0.0-a9"
77

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

pan_cortex_data_lake/credentials.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ def refresh(self, access_token=None, **kwargs):
477477
if not self.token_lock.locked():
478478
with self.token_lock:
479479
if access_token == self.access_token or access_token is None:
480-
if self.developer_token is not None:
480+
if self.developer_token is not None and not any(
481+
[self.access_token_, os.getenv("PAN_ACCESS_TOKEN")]
482+
):
481483
parsed_provider = urlparse(self.developer_token_provider)
482484
url = "{}://{}".format(
483485
parsed_provider.scheme, parsed_provider.netloc

pan_cortex_data_lake/query.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from .exceptions import CortexError, HTTPError
2222
from .httpclient import HTTPClient
23+
from . import __version__
2324

2425

2526
class QueryService(object):
@@ -110,9 +111,9 @@ def create_query(self, job_id=None, query_params=None, **kwargs):
110111
if value is not None:
111112
json.update({name: value})
112113
json.update(
113-
{ # auto-apply cortex-sdk client type and version
114-
"clientType": "cortex-sdk-python",
115-
"clientVersion": "0.1.0",
114+
{
115+
"clientType": "cortex-data-lake-python",
116+
"clientVersion": "%s" % __version__,
116117
}
117118
)
118119
endpoint = "/query/v2/jobs"
@@ -241,22 +242,23 @@ def iter_job_results(
241242
)
242243
if not r.ok:
243244
raise HTTPError("%s" % r.text)
244-
if r.json()["state"] == "DONE":
245-
page_cursor = r.json()["page"].get("pageCursor")
245+
r_json = r.json()
246+
if r_json["state"] == "DONE":
247+
page_cursor = r_json["page"].get("pageCursor")
246248
if page_cursor is not None:
247249
params["pageCursor"] = page_cursor
248250
yield r
249251
else:
250252
yield r
251253
break
252-
elif r.json()["state"] in ("RUNNING", "PENDING"):
254+
elif r_json["state"] in ("RUNNING", "PENDING"):
253255
yield r
254256
time.sleep(1)
255-
elif r.json()["state"] == "FAILED":
257+
elif r_json["state"] == "FAILED":
256258
yield r
257259
break
258260
else:
259-
raise CortexError("Bad state: %s" % r.json()["state"])
261+
raise CortexError("Bad state: %s" % r_json["state"])
260262

261263
def list_jobs(
262264
self,

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.0a8
2+
current_version = 2.0.0a9
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-a8",
25+
version="2.0.0-a9",
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)