From dc9f3e6acf06c8d2947566af3f78c70797d82e32 Mon Sep 17 00:00:00 2001 From: Kevin Steves Date: Wed, 13 Apr 2022 08:26:35 -0700 Subject: [PATCH] Workaround for autofocus API bug. Use af_in_progress to determine search completion. At some point, af_message was changed from "complete" to "success" to indicate search completion. --- doc/pan.afapi.rst | 17 +++++++++-------- lib/pan/afapi/v1_0.py | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/doc/pan.afapi.rst b/doc/pan.afapi.rst index fa1f6fc..04eaa87 100644 --- a/doc/pan.afapi.rst +++ b/doc/pan.afapi.rst @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. diff --git a/lib/pan/afapi/v1_0.py b/lib/pan/afapi/v1_0.py index 3058e17..8c6e081 100644 --- a/lib/pan/afapi/v1_0.py +++ b/lib/pan/afapi/v1_0.py @@ -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: