From 84b666633187e01db3ff5d5ce7700db80f906501 Mon Sep 17 00:00:00 2001 From: David Moore Date: Wed, 31 Jan 2024 14:35:21 -0500 Subject: [PATCH] New API endpoint to refresh all ACSs cover new endpoint in test_entities.py --- nailgun/entities.py | 21 +++++++++++++++++++++ tests/test_entities.py | 1 + 2 files changed, 22 insertions(+) diff --git a/nailgun/entities.py b/nailgun/entities.py index fe18435f..359ff640 100644 --- a/nailgun/entities.py +++ b/nailgun/entities.py @@ -523,6 +523,8 @@ def path(self, which=None): /katello/api/alternate_content_sources/:id/refresh bulk_refresh /katello/api/alternate_content_sources/bulk/refresh + bulk_refresh_all + /katello/api/alternate_content_sources/bulk/refresh_all bulk_destroy /katello/api/alternate_content_sources/bulk/destroy """ @@ -530,6 +532,7 @@ def path(self, which=None): return f'{super().path(which="self")}/{which}' elif which in ( 'bulk/refresh', + 'bulk/refresh_all', 'bulk/destroy', ): return f'{super().path(which="base")}/{which}' @@ -554,6 +557,24 @@ def refresh(self, synchronous=True, timeout=None, **kwargs): response = client.post(self.path('refresh'), **kwargs) return _handle_response(response, self._server_config, synchronous, timeout) + def bulk_refresh_all(self, synchronous=True, timeout=None, **kwargs): + """Refresh all ACSes present. + + :param synchronous: What should happen if the server returns an HTTP + 202 (accepted) status code? Wait for the task to complete if + ``True``. Immediately return the server's response otherwise. + :param timeout: Maximum number of seconds to wait until timing out. + Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``. + :param kwargs: Arguments to pass to requests. + :returns: The server's response, with all content decoded. + :raises: ``requests.exceptions.HTTPError`` If the server responds with + an HTTP 4XX or 5XX message. + """ + kwargs = kwargs.copy() # shadow the passed-in kwargs + kwargs.update(self._server_config.get_client_kwargs()) + response = client.post(self.path('bulk/refresh_all'), **kwargs) + return _handle_response(response, self._server_config, synchronous, timeout) + def bulk_refresh(self, synchronous=True, timeout=None, **kwargs): """Refresh the set of ACSes. diff --git a/tests/test_entities.py b/tests/test_entities.py index 4e09a81a..d61718e4 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -360,6 +360,7 @@ def test_noid_and_which(self): """Execute ``entity().path(which=…)``.""" for entity, which in ( (entities.AlternateContentSource, 'bulk/refresh'), + (entities.AlternateContentSource, 'bulk/refresh_all'), (entities.AlternateContentSource, 'bulk/destroy'), (entities.AnsibleRoles, 'sync'), (entities.AnsiblePlaybooks, 'sync'),