Package: httpmq
HTTP MQ - Python ClientPython client forhttpmqTable of Content1. Introduction2. Installation3. Examples4. Local Development1. IntroductionThis is aasyncPython client SDK forhttpmqbuilt aroundaiohttp, and uses the auto-generated data models ofhttpmq's OpenAPI specification. The auto-generated data models are placed underhttpmq/models. The module provides client objects for interacting with the management and data plane API ofhttpmq.importasyncioimportloggingimporthttpmqasyncdefasync_main(log:logging.Logger):try:# Create management plane clientmgmt_client=httpmq.ManagementClient(api_client=httpmq.APIClient(base_url="http://127.0.0.1:4100"))# Create data plane clientdata_client=httpmq.DataClient(api_client=httpmq.APIClient(base_url="http://127.0.0.1:4101"))# Check whether management plane is readyawaitmgmt_client.ready(context=httpmq.RequestContext())log.info("Management API ready")# Check whether data plane is readyawaitdata_client.ready(context=httpmq.RequestContext())log.info("Data plane API ready")finally:# Always disconnectawaitmgmt_client.disconnect()awaitdata_client.disconnect()2. Installation$pip3installhttpmq3. ExamplesHello World: basic example showing how to define the client.Manage Streams: managing streams through themanagementAPI.Manage Consumers: managing consumers through themanagementAPI.Sending and Receiving Messages: sending and receiving messages.4. Local DevelopmentNOTE:Though the described procedures supports local development, the samedocker-compose.yamlcan be used to create ahttpmqtest environment independent of this project.This project usesPoetryas the dependency management framework.$poetrycheck
Allset!A helper Makefile is also included to automate the common development tasks. The available make targets are:$makehelplintRunpythonlint
buildBuildmoduletestRununit-tests
one-testRunspecificunit-tests
installInstallmodule
uninstallUninstallmodule
reinstallReinstallmodule
cliRunvenvpythonCLI
composeBringupdevelopmentenvironmentviadocker-compose
cleanCleanupthepythonbuildartifactshelpDisplaythishelpscreenFirst, prepare the development environment:makeThis will callPoetryto setup the virtual environment, install dependencies, and build the module.Now, start the development environment:$makecompose
docker-compose-fdocker-compose.yamldown--volume
Removingnetworkhttpmq-python_httpmq-py-test
WARNING:Networkhttpmq-python_httpmq-py-testnotfound.
docker-compose-fdocker-compose.yamlup-d
Creatingnetwork"httpmq-python_httpmq-py-test"withdriver"bridge"Creatinghttpmq-python_httpmq-data_1...doneCreatinghttpmq-python_httpmq-mgmt_1...doneCreatinghttpmq-python_dev-nats_1...doneVerify the code passes unit-tests:$maketestpoetryrunpytest--verbose--junitxml=test-reports/test.xmltest/===============================================testsessionstarts===============================================platformlinux--Python3.10.6,pytest-7.1.2,pluggy-1.0.0--/home/harry/Git/HTTP_Message_Broker/httpmq-python/.venv/bin/python
cachedir:.pytest_cache
rootdir:/home/harry/Git/HTTP_Message_Broker/httpmq-python
collected11items

test/test_client.py::TestAPIClient::test_deletePASSED[9%]test/test_client.py::TestAPIClient::test_getPASSED[18%]test/test_client.py::TestAPIClient::test_postPASSED[27%]test/test_client.py::TestAPIClient::test_putPASSED[36%]test/test_client.py::TestAPIClient::test_sse_getPASSED[45%]test/test_dataplane.py::TestDataplane::test_basic_sanityPASSED[54%]test/test_dataplane.py::TestDataplane::test_message_splitterPASSED[63%]test/test_dataplane.py::TestDataplane::test_push_subscribePASSED[72%]test/test_management.py::TestManagement::test_basic_sanityPASSED[81%]test/test_management.py::TestManagement::test_consumer_managementPASSED[90%]test/test_management.py::TestManagement::test_stream_managementPASSED[100%]-----------generatedxmlfile:/home/harry/Git/HTTP_Message_Broker/httpmq-python/test-reports/test.xml-----------===============================================11passedin2.62s================================================A demo application,scripts/httpmq_test_cli.py, is also provided. It exercises all the functionalities of thehttpmqAPIs. These functionalities are separated into subcommands, and the associated usage message explains how to call each functionality.IMPORTANT:Before starting, perform$makeinstall
$poetryshellThis will install the locally built SDK package into the local virtual environment, and start a new shell within that virtual environment.$./scripts/httpmq_test_cli.py--help
Usage:httpmq_test_cli.py[OPTIONS]COMMAND[ARGS]...Demoapplicationfortryingoutfunctionalitiesofhttpmq

Options:--custom-ca-file,--caTEXTCustomCAfiletousewithHTTPclient[envvar:HTTP_CUSTOM_CA_FILE]--access-token,--atTEXTBeareraccesstokenusedforauthentication[envvar:HTTP_BEARER_ACCESS_TOKEN]--request-id,--ridTEXTRequestIDtousewiththiscall[default:6403e98e-d29a-478b-99e4-49ff07fb210f]-v,--verboseVerboselogging--helpShowthismessageandexit.

Commands:dataOperatethehttpmqdataplaneAPImanageOperatethehttpmqmanagementAPI$./scripts/httpmq_test_cli.pymanage--help
Usage:httpmq_test_cli.pymanage[OPTIONS]COMMAND[ARGS]...OperatethehttpmqmanagementAPI

Options:-s,--management-server-urlTEXTManagementserverURL[envvar:MANAGEMENT_SERVER_URL;default:http://127.0.0.1:4100]--helpShowthismessageandexit.

Commands:consumerManagesconsumersthroughhttpmqmanagementAPIreadyVerifythemanagementAPIisreadystreamManagesstreamsthroughhttpmqmanagementAPI$./scripts/httpmq_test_cli.pymanageready--help
Usage:httpmq_test_cli.pymanageready[OPTIONS]VerifythemanagementAPIisready

Options:--helpShowthismessageandexit.$./scripts/httpmq_test_cli.pymanagestream--help
Usage:httpmq_test_cli.pymanagestream[OPTIONS]COMMAND[ARGS]...ManagesstreamsthroughhttpmqmanagementAPI

Options:--helpShowthismessageandexit.

Commands:change-retentionChangedastream'smessageretentionpolicy.change-subjectChangedthetargetsubjectsofastreamthroughmanagementAPIcreateDefineanewstreamthroughhttpmqmanagementAPIdeleteDeleteonestreamthroughmanagementAPIgetReadinformationregardingonestreamthroughmanagementAPIlist-allListallstreamsthroughhttpmqmanagementAPI$./scripts/httpmq_test_cli.pymanageconsumer--help
Usage:httpmq_test_cli.pymanageconsumer[OPTIONS]COMMAND[ARGS]...ManagesconsumersthroughhttpmqmanagementAPI

Options:-s,--target-streamTEXTTargetstreamtooperateagainst[envvar:TARGET_STREAM;required]--helpShowthismessageandexit.

Commands:createDefineanewconsumerthroughhttpmqmanagementAPIdeleteDeleteaconsumerthroughhttpmqmanagementAPIgetReadinformationregardingoneconsumerthroughmanagementAPIlist-allListallconsumersofastreamthroughhttpmqmanagementAPI$./scripts/httpmq_test_cli.pydata--help
Usage:httpmq_test_cli.pydata[OPTIONS]COMMAND[ARGS]...OperatethehttpmqdataplaneAPI

Options:-s,--dataplane-server-urlTEXTDataplaneserverURL[envvar:DATAPLANE_SERVER_URL;default:http://127.0.0.1:4101]--helpShowthismessageandexit.

Commands:pubPublishmessagesonasubjectthroughhttpmqdataplaneAPIreadyVerifythedataplaneAPIisreadysubSubscribeformessagesasaconsumeronastreamthroughhttpmqdataplaneAPI$./scripts/httpmq_test_cli.pydataready--help
Usage:httpmq_test_cli.pydataready[OPTIONS]VerifythedataplaneAPIisready

Options:--helpShowthismessageandexit.