diff --git a/nailgun/entities.py b/nailgun/entities.py index 359ff640..65cc62e6 100644 --- a/nailgun/entities.py +++ b/nailgun/entities.py @@ -2498,11 +2498,13 @@ def path(self, which=None): /content_view_versions/incremental_update promote /content_view_versions//promote + republish_repositories + /content_view_versions//republish_repositories ``super`` is called otherwise. """ - if which in ("incremental_update", "promote"): + if which in ("incremental_update", "promote", "republish_repositories"): prefix = "base" if which == "incremental_update" else "self" return f"{super().path(prefix)}/{which}" return super().path(which) @@ -2545,6 +2547,25 @@ def promote(self, synchronous=True, timeout=None, **kwargs): response = client.post(self.path('promote'), **kwargs) return _handle_response(response, self._server_config, synchronous, timeout) + def republish_repositories(self, synchronous=True, timeout=None, **kwargs): + """Force a republish of the version's repositories' metadata. + + :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('republish_repositories'), **kwargs) + return _handle_response(response, self._server_config, synchronous, timeout) + class ContentViewFilterRule( Entity, @@ -6668,6 +6689,7 @@ def __init__(self, server_config=None, **kwargs): default='yum', required=True, ), + 'is_container_push': entity_fields.BooleanField(default=False), 'container_repository_name': entity_fields.StringField(), # Just setting `str_type='alpha'` will fail with this error: # {"docker_upstream_name":["must be a valid docker name"]}} @@ -6777,6 +6799,25 @@ def create_missing(self): self._fields['docker_upstream_name'].required = True super().create_missing() + def delete_with_args(self, synchronous=True, timeout=None, **kwargs): + """Delete a repository, and respect args passed to it. + + :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.delete(self.path(), **kwargs) + return _handle_response(response, self._server_config, synchronous, timeout) + def errata(self, synchronous=True, timeout=None, **kwargs): """List errata inside repository. diff --git a/tests/test_entities.py b/tests/test_entities.py index d61718e4..b46b19ff 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -310,6 +310,7 @@ def test_id_and_which(self): (entities.ContentView, 'copy'), (entities.ContentView, 'publish'), (entities.ContentViewVersion, 'promote'), + (entities.ContentViewVersion, 'republish_repositories'), (entities.DiscoveredHost, 'auto_provision'), (entities.DiscoveredHost, 'refresh_facts'), (entities.DiscoveredHost, 'reboot'), @@ -342,6 +343,7 @@ def test_id_and_which(self): (entities.Organization, 'repo_discover'), (entities.Product, 'sync'), (entities.PuppetClass, 'smart_class_parameters'), + (entities.Repository, 'delete_with_args'), (entities.Repository, 'errata'), (entities.Repository, 'packages'), (entities.Repository, 'remove_content'),