SatelliteQE / nailgun

Why use a hammer when you can use a nailgun.
GNU General Public License v3.0
46 stars 83 forks source link

Add flatpak support #1255

Open vsedmik opened 1 week ago

vsedmik commented 1 week ago

Description of changes

A couple of endpoints for Flatpak support is being added to the Satellite and we should cover them in nailgun.

Upstream API documentation, plugin, or feature links

Satellite's apidoc in Stream, sections Flatpak Remotes and Flatpak Remote Repositories.

Functional demonstration

sat = Satellite('satellite.redhat.com')
org = sat.api.Organization(id=1).read()
prod = sat.api.Product(organization=org).create()
fr = sat.api.FlatpakRemote(organization=org, name='FedoraFlatpakRemote', url='https://registry.fedoraproject.org/').create()
fr
Out[16]: robottelo.hosts.DecClass(name='FedoraFlatpakRemote', url='https://registry.fedoraproject.org/', organization=nailgun.entities.Organization(id=1), description=None, username=None, token=None, registry_url=None, seeded=False, id=6)

fr.description = 'This Is Fedora!'
fr.update(['description'])
Out[18]: robottelo.hosts.DecClass(name='FedoraFlatpakRemote', url='https://registry.fedoraproject.org/', organization=nailgun.entities.Organization(id=1), description='This Is Fedora!', username=None, token=None, registry_url=None, seeded=False, id=6)

fr.scan()
Out[19]: 
{'id': 'f257279b-9155-470b-9c3c-3501de3ee09f',
 'label': 'Actions::Katello::Flatpak::ScanRemote',
 'pending': False,
 'action': 'Scan remote',
 'username': 'admin',
 'started_at': '2024-11-21 15:18:52 UTC',
 'ended_at': '2024-11-21 15:18:58 UTC',
 'duration': '5.554937',
 'state': 'stopped',
 'result': 'success',
 'progress': 1.0,
 'input': {'remote_id': 6,
  'url': 'https://registry.fedoraproject.org//index/static?label%3Aorg.flatpak.ref%3Aexists=1&tag=latest',
  'current_request_id': '20e4eb30-4368-4dbd-8e76-aa9cfaaf7486',
  'current_timezone': 'UTC',
  'current_organization_id': None,
  'current_location_id': None,
  'current_user_id': 4},
 'output': {},
 'humanized': {'action': 'Scan remote',
  'input': [],
  'output': '',
  'errors': []},
 'cli_example': None,
 'start_at': '2024-11-21 15:18:52 UTC',
 'available_actions': {'cancellable': False, 'resumable': False}}

sat.api.FlatpakRemoteRepository(flatpak_remote_id=fr.id).search()
Out[21]: 
[robottelo.hosts.DecClass(flatpak_remote_id=6, name='0ad', label='93258e36-329b-45a7-9a59-8ebee0800b87', id=518),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='abiword', label='5b8bb100-6166-455b-84aa-69216db4d06f', id=519),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='aisleriot', label='1170133b-b159-4a92-808a-bd5798e1b357', id=520),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='alligator', label='027c0743-e7f5-460f-9fd3-24e82f80a0f2', id=521),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='amarok', label='5f89309f-965c-46af-bbff-735b7c8ce3ba', id=522),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='angelfish', label='7bfb4fd1-1c8e-4408-97c8-d84d16603a39', id=523),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='apostrophe', label='84620c36-6be4-4e95-82fa-72f8c80913af', id=524),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='aqualung', label='7980c60a-e149-422a-9a10-c4ec9c73a0c3', id=525),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='ardour', label='4a8ae6a6-7349-4f55-b682-90c69101b28f', id=526),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='arianna', label='4a84f1cd-d085-4501-9012-c556cc434fc0', id=527),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='ark', label='744daa6d-f2fe-40a2-88cb-3d87b484b61c', id=528),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='armacycles-ad', label='c09f1453-e63f-49a6-a4be-158d19b9e7b2', id=529),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='artikulate', label='d1473331-8a53-4738-869c-fd70775803be', id=530),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='astromenace', label='61eb8660-7721-417f-a9bf-df6661c1bf92', id=531),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='atlantik', label='d222131b-9689-4e35-8f8b-c087a5cf2dd4', id=532),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='atomes', label='22a0993a-47ef-476d-a1e1-eb62093f8f6a', id=533),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='atomix', label='1de01323-18ad-4fe2-9219-74c0e3af803a', id=534),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='audacious', label='75d5d3e4-e979-48b1-b00c-b9ba01a4e463', id=535),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='audacity', label='3ebfed6c-6eac-480e-bb3d-f05b9d539f95', id=536),
 robottelo.hosts.DecClass(flatpak_remote_id=6, name='audex', label='827c7b43-9782-413a-ad9a-daa5a456f8db', id=537)]

res = sat.api.FlatpakRemoteRepository(flatpak_remote_id=fr.id, id=537).mirror(product_id=prod.id)
res
Out[23]: 
{'id': '728b2594-c089-410d-8fc4-7fd97c97dd1c',
 'label': 'Actions::Katello::Flatpak::MirrorRemoteRepository',
 'pending': False,
 'action': 'Mirror Remote Repository',
 'username': 'admin',
 'started_at': '2024-11-21 15:22:24 UTC',
 'ended_at': '2024-11-21 15:22:25 UTC',
 'duration': '1.049321',
 'state': 'stopped',
 'result': 'success',
 'progress': 1.0,
 'input': {'services_checked': ['pulp3', 'candlepin', 'candlepin_auth'],
  'current_request_id': 'afdbfe71-5be4-48bd-99a7-a0e06f096038',
  'current_timezone': 'UTC',
  'current_organization_id': None,
  'current_location_id': None,
  'current_user_id': 4},
 'output': {},
 'humanized': {'action': 'Mirror Remote Repository',
  'input': [],
  'output': '',
  'errors': []},
 'cli_example': None,
 'start_at': '2024-11-21 15:22:24 UTC',
 'available_actions': {'cancellable': False, 'resumable': False}}

fr.delete()
sat.api.FlatpakRemote(organization=org).search(query={'search': f'name={fr.name}'})
Out[27]: []