blob: 6b81356fac535c6f7d6959950b40792a49c0c3e8 [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright BitBake Contributors
3#
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05004# SPDX-License-Identifier: GPL-2.0-only
5#
6
7import logging
8import bb.asyncrpc
9
10logger = logging.getLogger("BitBake.PRserv")
11
12class PRAsyncClient(bb.asyncrpc.AsyncClient):
13 def __init__(self):
14 super().__init__('PRSERVICE', '1.0', logger)
15
16 async def getPR(self, version, pkgarch, checksum):
Patrick Williamsac13d5f2023-11-24 18:59:46 -060017 response = await self.invoke(
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050018 {'get-pr': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum}}
19 )
20 if response:
21 return response['value']
22
23 async def importone(self, version, pkgarch, checksum, value):
Patrick Williamsac13d5f2023-11-24 18:59:46 -060024 response = await self.invoke(
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050025 {'import-one': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'value': value}}
26 )
27 if response:
28 return response['value']
29
30 async def export(self, version, pkgarch, checksum, colinfo):
Patrick Williamsac13d5f2023-11-24 18:59:46 -060031 response = await self.invoke(
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050032 {'export': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'colinfo': colinfo}}
33 )
34 if response:
35 return (response['metainfo'], response['datainfo'])
36
37 async def is_readonly(self):
Patrick Williamsac13d5f2023-11-24 18:59:46 -060038 response = await self.invoke(
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050039 {'is-readonly': {}}
40 )
41 if response:
42 return response['readonly']
43
44class PRClient(bb.asyncrpc.Client):
45 def __init__(self):
46 super().__init__()
47 self._add_methods('getPR', 'importone', 'export', 'is_readonly')
48
49 def _get_async_client(self):
50 return PRAsyncClient()