diff --git a/pynautobot/core/endpoint.py b/pynautobot/core/endpoint.py index 14b4109d..13beee23 100644 --- a/pynautobot/core/endpoint.py +++ b/pynautobot/core/endpoint.py @@ -697,13 +697,15 @@ def run_and_wait(self, *args, api_version=None, interval=5, max_rechecks=50, **k Examples: To run a job for verifying hostnames: - >>> nb.extras.jobs.run_and_wait( + >>> job_response = nb.extras.jobs.run_and_wait( class_path="local/data_quality/VerifyHostnames", data={"hostname_regex": ".*"}, commit=True, interval=5, max_rechecks=10, ) + >>> print(f"Job completed, Job Result ID: {job_response.job_result.id}") + Job completed, Job Result ID: 123 """ if max_rechecks <= 0: raise ValueError("Attribute `max_rechecks` must be a postive integer to prevent recursive loops.") diff --git a/tests/unit/test_endpoint.py b/tests/unit/test_endpoint.py index b4fb437f..675b493f 100644 --- a/tests/unit/test_endpoint.py +++ b/tests/unit/test_endpoint.py @@ -282,6 +282,7 @@ def test_run_and_wait_greater_v1_3(self, mock_post, mock_get): mock_get.return_value = {"schedule": {"id": 123}, "job_result": {"id": 123, "status": {"value": "SUCCESS"}}} test = test_obj.run_and_wait(job_id="test", interval=1, max_rechecks=5) self.assertEqual(test.job_result.status.value, "SUCCESS") + self.assertEqual(test.job_result.id, 123) @patch("pynautobot.core.query.Request.get", return_value=Mock()) @patch("pynautobot.core.query.Request.post", return_value=Mock())