I'm trying to build a tool which needs to do admin operation on a Apache Pulsar service. For some reason they have decided to not use plain JSON for the parameters that is in the body of the REST API instead they seem to use Jackson JSON serialisation. The tool I develop is written in Python 3.6 and I'm looking for ways to encode simple data structures into the Jackson JSON serialisation format or even finding the spec for the serialised format. Does such documentation or Python code exist? Since the typical data structures that is needed to be serialised are simple like a Set<AuthActions>
, with AuthActions
being an enum, it would be feasible to hand-code such things directly into the serialised format, if known.
Edited with code example:
import asyncio
import aiohttp
import ssl
import os
async def go(loop):
current_dir = os.path.abspath(os.path.dirname(__file__))
sslcontext = ssl.create_default_context(cafile=os.path.join(current_dir, 'cacert.pem'))
sslcontext.load_cert_chain(os.path.join(current_dir, 'super-cert.pem'),
os.path.join(current_dir, 'super-key.pem'))
async with aiohttp.ClientSession(loop=loop) as session:
async with session.post('https://localhost:8081/admin/namespaces/sample/standalone/ns1/permissions/testrole',
json={'actions': [0, 1]}, ssl=sslcontext) as resp:
print(resp.status)
print(await resp.text())
async with session.get('https://localhost:8081/admin/persistent/sample/standalone/ns1', ssl=sslcontext) as resp:
print(resp.status)
print(await resp.text())
loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))
loop.close()