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

Add support for the reclaim_space endpoint #1111

Merged
merged 1 commit into from
Mar 14, 2024
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
20 changes: 20 additions & 0 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,24 @@ def content_update_counts(self, synchronous=True, timeout=None, **kwargs):
response = client.post(self.path('content_update_counts'), **kwargs)
return _handle_response(response, self._server_config, synchronous, timeout)

def content_reclaim_space(self, synchronous=True, timeout=None, **kwargs):
"""Reclaim space for all on_demand repos synced on the Capsule.

: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 JSON decoded.
:raises: ``requests.exceptions.HTTPError`` If the server responds with
an HTTP 4XX or 5XX message.
"""
kwargs = kwargs.copy()
kwargs.update(self._server_config.get_client_kwargs())
response = client.post(self.path('content_reclaim_space'), **kwargs)
return _handle_response(response, self._server_config, synchronous, timeout)

def path(self, which=None):
"""Extend ``nailgun.entity_mixins.Entity.path``.

Expand All @@ -1017,6 +1035,8 @@ def path(self, which=None):
/capsules/<id>/content/counts
content_update_counts
/capsules/<id>/content/update_counts
content_reclaim_space
/capsules/<id>/content/reclaim_space

``super`` is called otherwise.

Expand Down
2 changes: 2 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ def test_capsule(self):
'content_sync',
'content_counts',
'content_update_counts',
'content_reclaim_space',
):
with self.subTest(which):
path = capsule.path(which)
Expand Down Expand Up @@ -2108,6 +2109,7 @@ def setUpClass(cls):
(entities.Capsule(**generic).content_sync, 'post'),
(entities.Capsule(**generic).content_counts, 'get'),
(entities.Capsule(**generic).content_update_counts, 'post'),
(entities.Capsule(**generic).content_reclaim_space, 'post'),
(entities.Role(**generic).clone, 'post'),
(entities.ProvisioningTemplate(**generic).build_pxe_default, 'post'),
(entities.ProvisioningTemplate(**generic).clone, 'post'),
Expand Down
Loading