Skip to content

Commit

Permalink
Workaround for autofocus API bug. Use af_in_progress to determine
Browse files Browse the repository at this point in the history
search completion.

At some point, af_message was changed from "complete" to "success" to
indicate search completion.
  • Loading branch information
kevinsteves committed Apr 13, 2022
1 parent 06a3a05 commit dc9f3e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 9 additions & 8 deletions doc/pan.afapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ samples_search_results(self, data=None, terminal=True)

The ``samples_search_results()`` method calls the
``samples_search()`` method, and then calls the ``samples_results()``
method until the response body contains a *complete* ``af_message``.
method until the response body ``af_in_progress`` name is
*false*.

This method is implemented as a generator function.

Expand Down Expand Up @@ -270,8 +271,8 @@ sessions_search_results(self, data=None, terminal=True)

The ``sessions_search_results()`` method calls the
``sessions_search()`` method, and then calls the
``sessions_results()`` method until the response body contains a
*complete* ``af_message``.
``sessions_results()`` method until the response body
``af_in_progress`` name is *false*.

This method is implemented as a generator function.

Expand Down Expand Up @@ -314,7 +315,7 @@ sessions_histogram_search_results(self, data=None, terminal=True)
The ``sessions_histogram_search_results()`` method calls the
``sessions_histogram_search()`` method, and then calls the
``sessions_histogram_results()`` method until the response body
contains a *complete* ``af_message``.
``af_in_progress`` name is *false*.

This method is implemented as a generator function.

Expand Down Expand Up @@ -356,8 +357,8 @@ sessions_aggregate_search_results(self, data=None, terminal=True)

The ``sessions_aggregate_search_results()`` method calls the
``sessions_aggregate_search()`` method, and then calls the
``sessions_aggregate_results()`` method until the response body contains
a *complete* ``af_message``.
``sessions_aggregate_results()`` method until the response body
``af_in_progress`` name is *false*.

This method is implemented as a generator function.

Expand Down Expand Up @@ -397,8 +398,8 @@ top_tags_search_results(self, data=None, terminal=True)

The ``top_tags_search_results()`` method calls the
``top_tags_search()`` method, and then calls the
``top_tags_results()`` method until the response body contains
a *complete* ``af_message``.
``top_tags_results()`` method until the response body
``af_in_progress`` name is *false*.

This method is implemented as a generator function.

Expand Down
6 changes: 4 additions & 2 deletions lib/pan/afapi/v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ def _search_results(self, data, search, results, terminal):
if obj is None:
raise PanAFapiError('Response not JSON')

msg = obj.get('af_message')
if msg is not None and msg == 'complete':
in_progress = obj.get('af_in_progress')
if in_progress is None:
raise PanAFapiError('No af_in_progress in response')
if not in_progress:
if terminal:
yield r
try:
Expand Down

0 comments on commit dc9f3e6

Please sign in to comment.