Skip to content

Commit 343a994

Browse files
jeremylenzclaude
andauthored
Remove subscription attachment methods (#1377)
* Remove subscription attachment methods from ActivationKey and HostSubscription Since Simple Content Access (SCA) is now the default and only mode for all organizations, subscription attachment to activation keys and hosts is no longer supported. This removes the following methods: ActivationKey: - add_subscriptions() - remove_subscriptions() - subscriptions() HostSubscription: - path() override for add_subscriptions and remove_subscriptions - subscriptions() - add_subscriptions() - remove_subscriptions() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove subscription attachment path references from ActivationKey and Host This commit removes the remaining subscription attachment path references: - ActivationKey.path(): Removed add_subscriptions, remove_subscriptions, and subscriptions from path definitions - Host.path(): Removed bulk/add_subscriptions and bulk/remove_subscriptions from path definitions - Host: Removed bulk_add_subscriptions() and bulk_remove_subscriptions() methods * Remove HostSubscription entity class and all related tests The HostSubscription entity was used to manage the relationship between hosts and subscriptions. Since subscription attachment is no longer supported in SCA mode, this entire entity class is obsolete and has been removed. Changes: - Removed HostSubscription class from entities.py - Removed HostSubscription from entity instantiation tests - Removed HostSubscription from required params tests - Removed test_hostsubscription() test method - Removed ActivationKey subscription method tests (add_subscriptions, remove_subscriptions, subscriptions) - Removed HostSubscription method tests (add_subscriptions, remove_subscriptions) * Remove subscription path tests for ActivationKey Remove test cases for add_subscriptions, remove_subscriptions, and subscriptions paths from test_id_and_which since these methods were removed from ActivationKey. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 986fdfa commit 343a994

2 files changed

Lines changed: 0 additions & 223 deletions

File tree

nailgun/entities.py

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ def path(self, which=None):
240240
241241
The format of the returned path depends on the value of ``which``:
242242
243-
add_subscriptions
244-
/activation_keys/<id>/add_subscriptions
245243
copy
246244
/activation_keys/<id>/copy
247245
content_override
@@ -250,23 +248,16 @@ def path(self, which=None):
250248
/activation_keys/<id>/product_content
251249
releases
252250
/activation_keys/<id>/releases
253-
remove_subscriptions
254-
/activation_keys/<id>/remove_subscriptions
255-
subscriptions
256-
/activation_keys/<id>/subscriptions
257251
258252
``super`` is called otherwise.
259253
260254
"""
261255
if which in (
262-
'add_subscriptions',
263256
'content_override',
264257
'copy',
265258
'host_collections',
266259
'product_content',
267260
'releases',
268-
'remove_subscriptions',
269-
'subscriptions',
270261
):
271262
return f'{super().path(which="self")}/{which}'
272263
return super().path(which)
@@ -297,25 +288,6 @@ def add_host_collection(self, synchronous=True, timeout=None, **kwargs):
297288
response = client.post(self.path('host_collections'), **kwargs)
298289
return _handle_response(response, self._server_config, synchronous, timeout)
299290

300-
def add_subscriptions(self, synchronous=True, timeout=None, **kwargs):
301-
"""Add subscriptions to activation key.
302-
303-
:param synchronous: What should happen if the server returns an HTTP
304-
202 (accepted) status code? Wait for the task to complete if
305-
``True``. Immediately return the server's response otherwise.
306-
:param timeout: Maximum number of seconds to wait until timing out.
307-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
308-
:param kwargs: Arguments to pass to requests.
309-
:returns: The server's response, with all JSON decoded.
310-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
311-
an HTTP 4XX or 5XX message.
312-
313-
"""
314-
kwargs = kwargs.copy() # shadow the passed-in kwargs
315-
kwargs.update(self._server_config.get_client_kwargs())
316-
response = client.put(self.path('add_subscriptions'), **kwargs)
317-
return _handle_response(response, self._server_config, synchronous, timeout)
318-
319291
def copy(self, synchronous=True, timeout=None, **kwargs):
320292
"""Copy provided activation key.
321293
@@ -337,44 +309,6 @@ def copy(self, synchronous=True, timeout=None, **kwargs):
337309
response = client.post(self.path('copy'), **kwargs)
338310
return _handle_response(response, self._server_config, synchronous, timeout)
339311

340-
def remove_subscriptions(self, synchronous=True, timeout=None, **kwargs):
341-
"""Remove subscriptions from an activation key.
342-
343-
:param synchronous: What should happen if the server returns an HTTP
344-
202 (accepted) status code? Wait for the task to complete if
345-
``True``. Immediately return the server's response otherwise.
346-
:param timeout: Maximum number of seconds to wait until timing out.
347-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
348-
:param kwargs: Arguments to pass to requests.
349-
:returns: The server's response, with all JSON decoded.
350-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
351-
an HTTP 4XX or 5XX message.
352-
353-
"""
354-
kwargs = kwargs.copy() # shadow the passed-in kwargs
355-
kwargs.update(self._server_config.get_client_kwargs())
356-
response = client.put(self.path('remove_subscriptions'), **kwargs)
357-
return _handle_response(response, self._server_config, synchronous, timeout)
358-
359-
def subscriptions(self, synchronous=True, timeout=None, **kwargs):
360-
"""Retrieve subscriptions on an activation key.
361-
362-
:param synchronous: What should happen if the server returns an HTTP
363-
202 (accepted) status code? Wait for the task to complete if
364-
``True``. Immediately return the server's response otherwise.
365-
:param timeout: Maximum number of seconds to wait until timing out.
366-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
367-
:param kwargs: Arguments to pass to requests.
368-
:returns: The server's response, with all JSON decoded.
369-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
370-
an HTTP 4XX or 5XX message.
371-
372-
"""
373-
kwargs = kwargs.copy() # shadow the passed-in kwargs
374-
kwargs.update(self._server_config.get_client_kwargs())
375-
response = client.get(self.path('subscriptions'), **kwargs)
376-
return _handle_response(response, self._server_config, synchronous, timeout)
377-
378312
def content_override(self, synchronous=True, timeout=None, **kwargs):
379313
"""Override the content of an activation key.
380314
@@ -4306,97 +4240,6 @@ def __init__(self, server_config=None, **kwargs):
43064240
}
43074241

43084242

4309-
class HostSubscription(Entity):
4310-
"""A representation of a Host Subscription entity."""
4311-
4312-
def __init__(self, server_config=None, **kwargs):
4313-
_check_for_value('host', kwargs)
4314-
self._fields = {
4315-
'content_label': entity_fields.StringField(),
4316-
'host': entity_fields.OneToOneField(Host, required=True),
4317-
'subscriptions': entity_fields.DictField(),
4318-
'value': entity_fields.StringField(),
4319-
}
4320-
super().__init__(server_config=server_config, **kwargs)
4321-
self._meta = {
4322-
'api_path': f'{self.host.path()}/subscriptions',
4323-
}
4324-
4325-
def path(self, which=None):
4326-
"""Extend ``nailgun.entity_mixins.Entity.path``.
4327-
4328-
The format of the returned path depends on the value of ``which``:
4329-
4330-
add_subscriptions
4331-
/hosts/<id>/add_subscriptions
4332-
remove_subscriptions
4333-
/hosts/<id>/remove_subscriptions
4334-
4335-
``super`` is called otherwise.
4336-
4337-
"""
4338-
if which in ('add_subscriptions', 'remove_subscriptions'):
4339-
return f'{super().path(which="base")}/{which}'
4340-
return super().path(which)
4341-
4342-
def subscriptions(self, synchronous=True, timeout=None, **kwargs):
4343-
"""Get subscriptions from host.
4344-
4345-
:param synchronous: What should happen if the server returns an HTTP
4346-
202 (accepted) status code? Wait for the task to complete if
4347-
``True``. Immediately return the server's response otherwise.
4348-
:param timeout: Maximum number of seconds to wait until timing out.
4349-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
4350-
:param kwargs: Arguments to pass to requests.
4351-
:returns: The server's response, with all JSON decoded.
4352-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
4353-
an HTTP 4XX or 5XX message.
4354-
4355-
"""
4356-
kwargs = kwargs.copy() # shadow the passed-in kwargs
4357-
kwargs.update(self._server_config.get_client_kwargs())
4358-
response = client.get(self.path('base'), **kwargs)
4359-
return _handle_response(response, self._server_config, synchronous, timeout)
4360-
4361-
def add_subscriptions(self, synchronous=True, timeout=None, **kwargs):
4362-
"""Add subscriptions to host.
4363-
4364-
:param synchronous: What should happen if the server returns an HTTP
4365-
202 (accepted) status code? Wait for the task to complete if
4366-
``True``. Immediately return the server's response otherwise.
4367-
:param timeout: Maximum number of seconds to wait until timing out.
4368-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
4369-
:param kwargs: Arguments to pass to requests.
4370-
:returns: The server's response, with all JSON decoded.
4371-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
4372-
an HTTP 4XX or 5XX message.
4373-
4374-
"""
4375-
kwargs = kwargs.copy() # shadow the passed-in kwargs
4376-
kwargs.update(self._server_config.get_client_kwargs())
4377-
response = client.put(self.path('add_subscriptions'), **kwargs)
4378-
return _handle_response(response, self._server_config, synchronous, timeout)
4379-
4380-
def remove_subscriptions(self, synchronous=True, timeout=None, **kwargs):
4381-
"""Remove subscriptions from host.
4382-
4383-
:param synchronous: What should happen if the server returns an HTTP
4384-
202 (accepted) status code? Wait for the task to complete if
4385-
``True``. Immediately return the server's response otherwise.
4386-
:param timeout: Maximum number of seconds to wait until timing out.
4387-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
4388-
:param kwargs: Arguments to pass to requests.
4389-
:returns: The server's response, with all JSON decoded.
4390-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
4391-
an HTTP 4XX or 5XX message.
4392-
4393-
"""
4394-
kwargs = kwargs.copy() # shadow the passed-in kwargs
4395-
kwargs.update(self._server_config.get_client_kwargs())
4396-
response = client.put(self.path('remove_subscriptions'), **kwargs)
4397-
return _handle_response(response, self._server_config, synchronous, timeout)
4398-
4399-
44004243
class Host(
44014244
Entity,
44024245
EntityCreateMixin,
@@ -4864,44 +4707,6 @@ def errata_applicability(self, synchronous=True, timeout=None, **kwargs):
48644707
response = client.put(self.path('errata/applicability'), **kwargs)
48654708
return _handle_response(response, self._server_config, synchronous, timeout)
48664709

4867-
def bulk_add_subscriptions(self, synchronous=True, timeout=None, **kwargs):
4868-
"""Add subscriptions to one or more hosts.
4869-
4870-
:param synchronous: What should happen if the server returns an HTTP
4871-
202 (accepted) status code? Wait for the task to complete if
4872-
``True``. Immediately return the server's response otherwise.
4873-
:param timeout: Maximum number of seconds to wait until timing out.
4874-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
4875-
:param kwargs: Arguments to pass to requests.
4876-
:returns: The server's response, with all content decoded.
4877-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
4878-
an HTTP 4XX or 5XX message.
4879-
4880-
"""
4881-
kwargs = kwargs.copy() # shadow the passed-in kwargs
4882-
kwargs.update(self._server_config.get_client_kwargs())
4883-
response = client.put(self.path('bulk/add_subscriptions'), **kwargs)
4884-
return _handle_response(response, self._server_config, synchronous, timeout)
4885-
4886-
def bulk_remove_subscriptions(self, synchronous=True, timeout=None, **kwargs):
4887-
"""Remove subscriptions from one or more hosts.
4888-
4889-
:param synchronous: What should happen if the server returns an HTTP
4890-
202 (accepted) status code? Wait for the task to complete if
4891-
``True``. Immediately return the server's response otherwise.
4892-
:param timeout: Maximum number of seconds to wait until timing out.
4893-
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
4894-
:param kwargs: Arguments to pass to requests.
4895-
:returns: The server's response, with all content decoded.
4896-
:raises: ``requests.exceptions.HTTPError`` If the server responds with
4897-
an HTTP 4XX or 5XX message.
4898-
4899-
"""
4900-
kwargs = kwargs.copy() # shadow the passed-in kwargs
4901-
kwargs.update(self._server_config.get_client_kwargs())
4902-
response = client.put(self.path('bulk/remove_subscriptions'), **kwargs)
4903-
return _handle_response(response, self._server_config, synchronous, timeout)
4904-
49054710
def bulk_available_incremental_updates(self, synchronous=True, timeout=None, **kwargs):
49064711
"""Get available_incremental_updates for one or more hosts.
49074712
@@ -5119,8 +4924,6 @@ def path(self, which=None):
51194924
return f'{super().path(which="self")}/{which}'
51204925
elif which in (
51214926
'bootc_images',
5122-
'bulk/add_subscriptions',
5123-
'bulk/remove_subscriptions',
51244927
'bulk/available_incremental_updates',
51254928
'bulk/traces',
51264929
'bulk/resolve_traces',

tests/test_entities.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def test_init_succeeds(self):
197197
(entities.ContentViewFilterRule, {'content_view_filter': 1}),
198198
(entities.ExternalUserGroup, {'usergroup': 1}),
199199
(entities.HostPackage, {'host': 1}),
200-
(entities.HostSubscription, {'host': 1}),
201200
(entities.Interface, {'host': 1}),
202201
(entities.Image, {'compute_resource': 1}),
203202
(entities.OperatingSystemParameter, {'operatingsystem': 1}),
@@ -233,7 +232,6 @@ def test_required_params(self):
233232
entities.ContentViewFilterRule,
234233
entities.ExternalUserGroup,
235234
entities.HostPackage,
236-
entities.HostSubscription,
237235
entities.Image,
238236
entities.OverrideValue,
239237
entities.OperatingSystemParameter,
@@ -296,13 +294,10 @@ def test_nowhich(self):
296294
def test_id_and_which(self):
297295
"""Execute ``entity(id=…).path(which=…)``."""
298296
for entity, which in (
299-
(entities.ActivationKey, 'add_subscriptions'),
300297
(entities.ActivationKey, 'content_override'),
301298
(entities.ActivationKey, 'copy'),
302299
(entities.ActivationKey, 'host_collections'),
303300
(entities.ActivationKey, 'releases'),
304-
(entities.ActivationKey, 'remove_subscriptions'),
305-
(entities.ActivationKey, 'subscriptions'),
306301
(entities.AbstractComputeResource, 'available_images'),
307302
(entities.AbstractComputeResource, 'available_zones'),
308303
(entities.AbstractComputeResource, 'available_flavors'),
@@ -595,21 +590,6 @@ def test_capsule(self):
595590
self.assertIn(f'capsules/{capsule.id}/content/{which_parts[1]}', path)
596591
self.assertRegex(path, fr'{which_parts[0]}/{which_parts[1]}$')
597592

598-
def test_hostsubscription(self):
599-
"""Test :meth:`nailgun.entities.HostSubscription.path`.
600-
601-
Assert that the following return appropriate paths:
602-
603-
* ``HostSubscription(host=…).path('add_subscriptions')``
604-
* ``HostSubscription(host=…).path('remove_subscriptions')``
605-
"""
606-
sub = entities.HostSubscription(self.cfg, host=gen_integer(1, 100))
607-
for which in ('add_subscriptions', 'remove_subscriptions'):
608-
with self.subTest(which):
609-
path = sub.path(which)
610-
self.assertIn(f'hosts/{sub.host.id}/subscriptions/{which}', path)
611-
self.assertRegex(path, fr'{which}$')
612-
613593

614594
class CreateTestCase(TestCase):
615595
"""Tests for :meth:`nailgun.entity_mixins.EntityCreateMixin.create`."""
@@ -2114,7 +2094,6 @@ def setUpClass(cls):
21142094
generic = {'server_config': cfg, 'id': 1}
21152095
external_usergroup = {'server_config': cfg, 'id': 1, 'usergroup': 2}
21162096
sync_plan = {'server_config': cfg, 'id': 1, 'organization': 2}
2117-
hostsubscription = {'server_config': cfg, 'host': 1}
21182097
cls.methods_requests = (
21192098
(entities.AbstractComputeResource(**generic).available_flavors, 'get'),
21202099
(entities.AbstractComputeResource(**generic).available_images, 'get'),
@@ -2123,9 +2102,6 @@ def setUpClass(cls):
21232102
(entities.AbstractComputeResource(**generic).associate, 'put'),
21242103
(entities.AbstractComputeResource(**generic).images, 'get'),
21252104
(entities.ActivationKey(**generic).add_host_collection, 'post'),
2126-
(entities.ActivationKey(**generic).add_subscriptions, 'put'),
2127-
(entities.ActivationKey(**generic).remove_subscriptions, 'put'),
2128-
(entities.ActivationKey(**generic).subscriptions, 'get'),
21292105
(entities.ActivationKey(**generic).content_override, 'put'),
21302106
(entities.ActivationKey(**generic).product_content, 'get'),
21312107
(entities.ActivationKey(**generic).remove_host_collection, 'put'),
@@ -2177,8 +2153,6 @@ def setUpClass(cls):
21772153
(entities.HostGroup(**generic).clone, 'post'),
21782154
(entities.HostGroup(**generic).list_ansible_roles, 'get'),
21792155
(entities.HostGroup(**generic).list_scparams, 'get'),
2180-
(entities.HostSubscription(**hostsubscription).add_subscriptions, 'put'),
2181-
(entities.HostSubscription(**hostsubscription).remove_subscriptions, 'put'),
21822156
(entities.Product(**generic).sync, 'post'),
21832157
(entities.ProductBulkAction(**generic).destroy, 'put'),
21842158
(entities.ProductBulkAction(**generic).sync, 'put'),

0 commit comments

Comments
 (0)