diff --git a/kernelci/legacy/cli/__init__.py b/kernelci/legacy/cli/__init__.py index 514b059176..9b76859f5b 100644 --- a/kernelci/legacy/cli/__init__.py +++ b/kernelci/legacy/cli/__init__.py @@ -13,7 +13,6 @@ api, job, node, - pubsub, sched, show, storage, @@ -24,7 +23,6 @@ 'api': api.main, 'job': job.main, 'node': node.main, - 'pubsub': pubsub.main, 'sched': sched.main, 'show': show.main, 'storage': storage.main, diff --git a/kernelci/legacy/cli/pubsub.py b/kernelci/legacy/cli/pubsub.py deleted file mode 100644 index 6f469bcc75..0000000000 --- a/kernelci/legacy/cli/pubsub.py +++ /dev/null @@ -1,82 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -# -# Copyright (C) 2023 Collabora Limited -# Author: Guillaume Tucker - -"""Tool to interact with the Pub/Sub interface""" - -import json -import sys - -import kernelci - -from .base import Args, sub_main -from .base_api import APICommand - - -class cmd_subscribe(APICommand): # pylint: disable=invalid-name - """Subscribe to a Pub/Sub channel""" - args = APICommand.args + [Args.api_token, Args.channel] - - def _api_call(self, api, configs, args): - sub_id = api.subscribe(args.channel) - print(sub_id) - return True - - -class cmd_unsubscribe(APICommand): # pylint: disable=invalid-name - """Unscribe from a Pub/Sub channel""" - args = APICommand.args + [Args.api_token, Args.sub_id] - - def _api_call(self, api, configs, args): - api.unsubscribe(args.sub_id) - return True - - -class cmd_send_event(APICommand): # pylint: disable=invalid-name - """Read some data on stdin and send it as an event on a channel""" - args = APICommand.args + [Args.api_token, Args.channel] - opt_args = [ - { - 'name': '--type', - 'help': "CloudEvent type, api.kernelci.org by default", - }, - { - 'name': '--source', - 'help': "CloudEvent source, https://api.kernelci.org/ by default", - }, - { - 'name': '--json', - 'action': 'store_true', - 'help': "Parse input data as JSON", - }, - ] - - def _api_call(self, api, configs, args): - data = sys.stdin.read() - if args.json: - data = json.loads(data) - api.send_event(args.channel, {'data': data}) - return True - - -class cmd_receive_event(APICommand): # pylint: disable=invalid-name - """Wait and receive an event from a subscription and print on stdout""" - args = APICommand.args + [Args.api_token, Args.sub_id] - opt_args = APICommand.opt_args + [Args.indent] - - def _api_call(self, api, configs, args): - helper = kernelci.api.helper.APIHelper(api) - event = helper.receive_event_data(args.sub_id) - if isinstance(event, str): - print(event.strip()) - elif isinstance(event, dict): - self._print_json(event, args.indent) - else: - print(event) - return True - - -def main(args=None): - """Entry point for the command line tool""" - sub_main("pubsub", globals(), args)