Skip to main content

virsh-sandbox API

Project description

Virsh Sandbox

API for managing virtual machine sandboxes using libvirt

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.0.1-beta
  • Package version: 0.0.21-beta
  • Generator version: 7.19.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.9+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import virsh_sandbox

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import virsh_sandbox

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

Unified Client (Recommended)

The SDK provides a unified VirshSandbox client that simplifies API usage with flattened parameters:

import asyncio
from virsh_sandbox import VirshSandbox

async def main():
    # Create a unified client
    client = VirshSandbox(
        host="http://localhost:8080",
        tmux_host="http://localhost:8081"  # Optional: separate host for tmux operations
    )

    # Create a sandbox with simple parameters - no request objects needed!
    result = await client.sandbox.create_sandbox(
        source_vm_name="ubuntu-base",
        vm_name="my-sandbox",
        cpu=2,
        memory_mb=4096
    )

    # Run commands with flattened parameters
    output = await client.command.run_command(
        command="ls",
        args=["-la"],
        timeout=30
    )

    # File operations
    content = await client.file.read_file(path="/etc/hosts")

    # Tmux operations
    panes = await client.tmux.list_tmux_panes()

    # Clean up
    await client.close()

# Or use as async context manager for automatic cleanup
async def main_with_context():
    async with VirshSandbox(host="http://localhost:8080") as client:
        # All APIs accessible through namespaced properties:
        # - client.sandbox   (SandboxOperations)
        # - client.command   (CommandOperations)
        # - client.file      (FileOperations)
        # - client.tmux      (TmuxOperations)
        # - client.ansible   (AnsibleOperations)
        # - client.audit     (AuditOperations)
        # - client.health    (HealthOperations)
        # - client.human     (HumanOperations)
        # - client.plan      (PlanOperations)
        # - client.vms       (VMsOperations)

        await client.sandbox.create_sandbox(source_vm_name="base-vm")

asyncio.run(main())

Individual API Classes (Advanced)

For more control, you can use the individual API classes directly with request objects:

import virsh_sandbox
from virsh_sandbox.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = virsh_sandbox.Configuration(
    host = "http://localhost"
)


# Enter a context with an instance of the API client
with virsh_sandbox.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = virsh_sandbox.AccessApi(api_client)

    try:
        # Get the SSH CA public key
        api_response = api_instance.get_ca_public_key()
        print("The response of AccessApi->get_ca_public_key:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AccessApi->get_ca_public_key: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
AccessApi get_ca_public_key GET /v1/access/ca-pubkey Get the SSH CA public key
AccessApi get_certificate GET /v1/access/certificate/{certID} Get certificate details
AccessApi list_certificates GET /v1/access/certificates List certificates
AccessApi list_sessions GET /v1/access/sessions List sessions
AccessApi record_session_end POST /v1/access/session/end Record session end
AccessApi record_session_start POST /v1/access/session/start Record session start
AccessApi request_access POST /v1/access/request Request SSH access to a sandbox
AccessApi revoke_certificate DELETE /v1/access/certificate/{certID} Revoke a certificate
AnsibleApi create_ansible_job POST /v1/ansible/jobs Create Ansible job
AnsibleApi get_ansible_job GET /v1/ansible/jobs/{job_id} Get Ansible job
AnsibleApi stream_ansible_job_output GET /v1/ansible/jobs/{job_id}/stream Stream Ansible job output
AnsiblePlaybooksApi add_playbook_task POST /v1/ansible/playbooks/{playbook_name}/tasks Add task to playbook
AnsiblePlaybooksApi create_playbook POST /v1/ansible/playbooks Create playbook
AnsiblePlaybooksApi delete_playbook DELETE /v1/ansible/playbooks/{playbook_name} Delete playbook
AnsiblePlaybooksApi delete_playbook_task DELETE /v1/ansible/playbooks/{playbook_name}/tasks/{task_id} Delete task
AnsiblePlaybooksApi export_playbook GET /v1/ansible/playbooks/{playbook_name}/export Export playbook
AnsiblePlaybooksApi get_playbook GET /v1/ansible/playbooks/{playbook_name} Get playbook
AnsiblePlaybooksApi list_playbooks GET /v1/ansible/playbooks List playbooks
AnsiblePlaybooksApi reorder_playbook_tasks PATCH /v1/ansible/playbooks/{playbook_name}/tasks/reorder Reorder tasks
AnsiblePlaybooksApi update_playbook_task PUT /v1/ansible/playbooks/{playbook_name}/tasks/{task_id} Update task
HealthApi get_health GET /v1/health Health check
SandboxApi create_sandbox POST /v1/sandboxes Create a new sandbox
SandboxApi create_snapshot POST /v1/sandboxes/{id}/snapshot Create snapshot
SandboxApi destroy_sandbox DELETE /v1/sandboxes/{id} Destroy sandbox
SandboxApi diff_snapshots POST /v1/sandboxes/{id}/diff Diff snapshots
SandboxApi discover_sandbox_ip GET /v1/sandboxes/{id}/ip Discover sandbox IP
SandboxApi generate_configuration POST /v1/sandboxes/{id}/generate/{tool} Generate configuration
SandboxApi get_sandbox GET /v1/sandboxes/{id} Get sandbox details
SandboxApi inject_ssh_key POST /v1/sandboxes/{id}/sshkey Inject SSH key into sandbox
SandboxApi list_sandbox_commands GET /v1/sandboxes/{id}/commands List sandbox commands
SandboxApi list_sandboxes GET /v1/sandboxes List sandboxes
SandboxApi publish_changes POST /v1/sandboxes/{id}/publish Publish changes
SandboxApi run_sandbox_command POST /v1/sandboxes/{id}/run Run command in sandbox
SandboxApi start_sandbox POST /v1/sandboxes/{id}/start Start sandbox
SandboxApi stream_sandbox_activity GET /v1/sandboxes/{id}/stream Stream sandbox activity
VMsApi list_virtual_machines GET /v1/vms List all VMs

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virsh_sandbox-0.0.21b0.tar.gz (84.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

virsh_sandbox-0.0.21b0-py3-none-any.whl (313.7 kB view details)

Uploaded Python 3

File details

Details for the file virsh_sandbox-0.0.21b0.tar.gz.

File metadata

  • Download URL: virsh_sandbox-0.0.21b0.tar.gz
  • Upload date:
  • Size: 84.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for virsh_sandbox-0.0.21b0.tar.gz
Algorithm Hash digest
SHA256 5f4360dbc769054c8b896a2e75f27575db1e0588ea9eea3eb0f9819745031f84
MD5 5bcec205d1e95bec4d13caeea177d5e3
BLAKE2b-256 d78f9355ae7e9202161e47e301a73fe1e6a78cd2f681b64e7fa9a09a0a77d0f1

See more details on using hashes here.

File details

Details for the file virsh_sandbox-0.0.21b0-py3-none-any.whl.

File metadata

File hashes

Hashes for virsh_sandbox-0.0.21b0-py3-none-any.whl
Algorithm Hash digest
SHA256 c012d1695d403547821910ccc4b526e9b863c9607ebd7706963aa7a9b6c3334b
MD5 c70bbac6c571ff30cd4ce96d1c3b3eaf
BLAKE2b-256 98bf99c85271ce186d9d62941e2ee7356c09bacd6e8a0a9e910cbd97111dd910

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page