Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Renrut5 committed Jan 16, 2025
1 parent ec0d902 commit b19d773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pynautobot/core/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit b19d773

Please sign in to comment.