Skip to content

Commit

Permalink
New API endpoint to refresh all ACSs (#1086)
Browse files Browse the repository at this point in the history
cover new endpoint in test_entities.py

(cherry picked from commit 68976fe)
  • Loading branch information
damoore044 authored and web-flow committed Feb 20, 2024
1 parent 949e877 commit d817ebf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,16 @@ 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
"""
if which == "refresh":
return f'{super().path(which="self")}/{which}'
elif which in (
'bulk/refresh',
'bulk/refresh_all',
'bulk/destroy',
):
return f'{super().path(which="base")}/{which}'
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit d817ebf

Please sign in to comment.