Client for the XPipe API
Project description
xpipe_client
Python client for the XPipe API
Installation
python3 -m pip install git+https://github.com/coandco/python_xpipe_client
Usage
from xpipe_client import Client
# By default, Client() will read the API key from xpipe_auth on the local filesystem
# and talk to the XPipe API on localhost. To connect to a remote instance with an API
# key, use Client(token="foo", base_url = "http://servername:21723")
client = Client()
# connection_query accepts glob-based filters on the category, connection name, and connection type
all_connections = client.connection_query()
# Each connection includes uuid, category, connection, and type information
first_connection_uuid = all_connections[0]["uuid"]
# Before any shell commands can be run, a shell session must be started on a connection
client.shell_start(first_connection_uuid)
# Prints {'exitCode': 0, 'stdout': 'hello world', 'stderr': ''}
print(client.shell_exec(first_connection_uuid, "echo hello world"))
# Clean up after ourselves
client.shell_stop(first_connection_uuid)
There's also an async version of the client that can be accessed as AsyncClient:
import asyncio
from xpipe_client import AsyncClient
async def main():
# By default, AsyncClient() will read the API key from xpipe_auth on the local filesystem
# and talk to the XPipe API on localhost. To connect to a remote instance with an API
# key, use Client(token="foo", base_url = "http://servername:21723")
client = AsyncClient()
# connection_query accepts glob-based filters on the category, connection name, and connection type
all_connections = await client.connection_query()
# Each connection includes uuid, category, connection, and type information
first_connection_uuid = all_connections[0]["uuid"]
# Before any shell commands can be run, a shell session must be started on a connection
await client.shell_start(first_connection_uuid)
# Prints {'exitCode': 0, 'stdout': 'hello world', 'stderr': ''}
print(await client.shell_exec(first_connection_uuid, "echo hello world"))
# Clean up after ourselves
await client.shell_stop(first_connection_uuid)
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xpipe_client-0.1.11.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for xpipe_client-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96e30a1fa9e95cf721c6208fec0374810cfae29f4007acee953ab97b9fe0d160 |
|
MD5 | 41b28010aad20fcdec4e18c9b534fdd5 |
|
BLAKE2b-256 | 4d6e0742f411eb80766db1d87222724e7a002aab1cc47a87da5a3051313eb770 |