diff --git a/nailgun/entities.py b/nailgun/entities.py index 034c4b1a..d29e58b5 100644 --- a/nailgun/entities.py +++ b/nailgun/entities.py @@ -1057,6 +1057,7 @@ def path(self, which=None): /capsules//content/reclaim_space content_verify_checksum /capsules//content/verify_checksum + ``super`` is called otherwise. """ @@ -6336,11 +6337,13 @@ def path(self, which=None): /products/bulk/sync_plan http_proxy /products/bulk/http_proxy + verify_checksum + /products/bulk/verify_checksum ``super`` is called otherwise. """ - if which in ("destroy", "sync", "sync_plan", "http_proxy"): + if which in ("destroy", "sync", "sync_plan", "http_proxy", "verify_checksum"): return f'{super().path(which="base")}/{which}' return super().path(which) @@ -6420,6 +6423,25 @@ def sync_plan(self, synchronous=True, timeout=None, **kwargs): response = client.put(self.path('sync_plan'), **kwargs) return _handle_response(response, self._server_config, synchronous, timeout) + def verify_checksum(self, synchronous=True, timeout=None, **kwargs): + """Verify checksum for one or more products. + + :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() # shadow the passed-in kwargs + kwargs.update(self._server_config.get_client_kwargs()) + response = client.put(self.path('verify_checksum'), **kwargs) + return _handle_response(response, self._server_config, synchronous, timeout) + class PartitionTable( Entity, @@ -6868,6 +6890,8 @@ def path(self, which=None): /repositories//remove_content sync /repositories//sync + verify_checksum + /repositories//verify_checksum upload_content /repositories//upload_content import_uploads @@ -6883,6 +6907,7 @@ def path(self, which=None): 'module_streams', 'remove_content', 'sync', + 'verify_checksum', 'import_uploads', 'upload_content', ): @@ -6953,6 +6978,25 @@ def sync(self, synchronous=True, timeout=None, **kwargs): response = client.post(self.path('sync'), **kwargs) return _handle_response(response, self._server_config, synchronous, timeout) + def verify_checksum(self, synchronous=True, timeout=None, **kwargs): + """Verify checksum of repository contents. + + :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() # shadow the passed-in kwargs + kwargs.update(self._server_config.get_client_kwargs()) + response = client.post(self.path('verify_checksum'), **kwargs) + return _handle_response(response, self._server_config, synchronous, timeout) + def upload_content(self, synchronous=True, timeout=None, **kwargs): """Upload a file or files to the current repository. diff --git a/tests/test_entities.py b/tests/test_entities.py index 1f9d568f..232c7c63 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -347,6 +347,7 @@ def test_id_and_which(self): (entities.Repository, 'packages'), (entities.Repository, 'remove_content'), (entities.Repository, 'sync'), + (entities.Repository, 'verify_checksum'), (entities.Repository, 'upload_content'), (entities.RHCIDeployment, 'deploy'), (entities.ScapContents, 'xml'), @@ -415,6 +416,7 @@ def test_no_such_path_error(self): (entities.Organization, 'repo_discover'), (entities.Product, 'repository_sets'), (entities.Repository, 'sync'), + (entities.Repository, 'verify_checksum'), (entities.Repository, 'upload_content'), (entities.ScapContents, 'xml'), (entities.RHCIDeployment, 'deploy'), @@ -2159,6 +2161,7 @@ def setUpClass(cls): (entities.ProductBulkAction(**generic).sync, 'put'), (entities.ProductBulkAction(**generic).http_proxy, 'put'), (entities.ProductBulkAction(**generic).sync_plan, 'put'), + (entities.ProductBulkAction(**generic).verify_checksum, 'put'), (entities.PuppetClass(**generic).list_scparams, 'get'), (entities.RHCIDeployment(**generic).deploy, 'put'), (entities.RecurringLogic(**generic).cancel, 'post'), @@ -2167,6 +2170,7 @@ def setUpClass(cls): (entities.Repository(**generic).module_streams, 'get'), (entities.Repository(**generic).remove_content, 'put'), (entities.Repository(**generic).sync, 'post'), + (entities.Repository(**generic).verify_checksum, 'post'), (entities.ScapContents(**generic).xml, 'get'), (entities.SmartProxy(**generic).import_puppetclasses, 'post'), (entities.SmartProxy(**generic).refresh, 'put'),