Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.15.z] New API endpoint for bulk/refresh all ACSs #1090

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading