A Python SDK for Royal TSX/TS - create and manage connections, credentials, and folders programmatically
Project description
Royal SDK
A Python SDK for Royal TSX/TS services, allowing you to programmatically create and manage connections, credentials, and folders.
Installation
pip install royal-sdk
Quick Start
Basic Usage
from royal_sdk import (
DynamicFolder,
TerminalConnection,
TerminalConnectionType,
FileTransferConnection,
FileTransferConnectionType,
UsernameAndPassword,
KeySequenceTask,
Folder
)
# Create a dynamic folder (for Royal TSX dynamic folder scripts)
folder = DynamicFolder()
# Create credentials
cred = UsernameAndPassword(
cred_id=1,
name="My Server Credentials",
username="admin",
password="secret123"
)
# Create SSH terminal connection
ssh_conn = TerminalConnection(
conn_type=TerminalConnectionType.SSH,
name="Production Server",
host="192.168.1.100",
port=22
)
ssh_conn.set_credential(cred)
# Create SFTP file transfer connection
sftp_conn = FileTransferConnection(
conn_type=FileTransferConnectionType.SFTP,
name="File Transfer",
host="192.168.1.100",
port=22
)
sftp_conn.set_credential(cred)
sftp_conn.set_local_path("/Users/username/Downloads")
sftp_conn.set_remote_path("/home/admin")
# Create key sequence tasks
task1 = KeySequenceTask(
name="System Check",
key_sequence="whoami\nuptime\ndf -h"
)
task2 = KeySequenceTask(
name="Switch to Root",
key_sequence="sudo su -",
no_confirmation_required=True
)
# Add everything to folder
folder.add(cred.objectify())
folder.add(ssh_conn.objectify())
folder.add(sftp_conn.objectify())
folder.add(task1.objectify())
folder.add(task2.objectify())
# Output the dynamic folder JSON
folder.execute()
Creating Static Folders
from royal_sdk import Folder, TerminalConnection, TerminalConnectionType
# Create connections
conn1 = TerminalConnection(
conn_type=TerminalConnectionType.SSH,
name="Server 1",
host="server1.example.com"
)
conn2 = TerminalConnection(
conn_type=TerminalConnectionType.SSH,
name="Server 2",
host="server2.example.com"
)
# Create a static folder
server_folder = Folder("Production Servers", [
conn1.objectify(),
conn2.objectify()
])
print(server_folder.objectify())
API Reference
Credentials
UsernameAndPassword
Create username/password credentials.
cred = UsernameAndPassword(
cred_id=1,
name="My Credentials",
username="user",
password="pass"
)
PrivateKey
Create private key credentials.
from royal_sdk import PrivateKey
cred = PrivateKey(
cred_id=2,
name="SSH Key",
private_key_content="-----BEGIN PRIVATE KEY-----...",
passphrase="key_passphrase"
)
Connections
TerminalConnection
Create SSH terminal connections.
from royal_sdk import TerminalConnection, TerminalConnectionType
conn = TerminalConnection(
conn_type=TerminalConnectionType.SSH,
name="My Server",
host="example.com",
port=22 # optional, defaults to 22
)
FileTransferConnection
Create SFTP file transfer connections.
from royal_sdk import FileTransferConnection, FileTransferConnectionType
conn = FileTransferConnection(
conn_type=FileTransferConnectionType.SFTP,
name="File Server",
host="files.example.com",
port=22 # optional, defaults to 22
)
# Set local and remote paths
conn.set_local_path("/Users/username/Downloads")
conn.set_remote_path("/home/user/files")
Tasks
KeySequenceTask
Create key sequence tasks for automation.
from royal_sdk import KeySequenceTask
# Basic key sequence task
task = KeySequenceTask(
name="Switch to root user",
key_sequence="sudo su -"
)
# Advanced key sequence task with options
task = KeySequenceTask(
name="Check system status",
key_sequence="whoami{ENTER}uptime{ENTER}df -h",
no_confirmation_required=True, # Don't ask for confirmation
execution_mode=2 # 0=No change, 1=Keyboard simulation, 2=Direct mode
)
# Get the task object for use in folders
task_obj = task.objectify()
Parameters:
name: Task display namekey_sequence: Commands/keys to execute (use\nfor new lines)no_confirmation_required: Skip confirmation dialog (default: False)execution_mode: How to execute the keys (default: 2)- 0 = Do not change
- 1 = Keyboard input simulation
- 2 = Direct mode (where supported)
Folders
DynamicFolder
For Royal TSX dynamic folder scripts.
from royal_sdk import DynamicFolder
folder = DynamicFolder()
folder.add(connection.objectify())
folder.execute() # Outputs JSON to stdout
Folder
For static folder structures.
from royal_sdk import Folder
folder = Folder("My Folder", [
connection1.objectify(),
connection2.objectify()
])
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file royal_sdk-0.1.2.tar.gz.
File metadata
- Download URL: royal_sdk-0.1.2.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e7a971585a361ac480137372ea00ee3f67ab2e77b7e243b47572473539c1459
|
|
| MD5 |
c6dc2241360960ab5b7148e99a167780
|
|
| BLAKE2b-256 |
cdf88a5b6c0deccd2f56c0dd58a3189429907dcf19403a6f312e3965de6a4c01
|
File details
Details for the file royal_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: royal_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
144acfb12f0e81aeb6a9b387a8e4c20ff40c338e887c59e71f38ecfe4b290b26
|
|
| MD5 |
637f9ce1e68541d2591f297a4e3d2679
|
|
| BLAKE2b-256 |
95490afdf7744a401bff921ebf003b49418e13463968d4e2b4436eb2e0866488
|