Skip to content

konopski/tosca-commander-api

Repository files navigation

TOSCA Commander REST API - Jython Wrapper

Complete Jython-compatible wrapper for TOSCA Commander REST API with pluggable HTTP clients.

Quick Start

from tosca_commander_api_v2 import connect

# Connect and open workspace
session = connect(
    "http://localhost:1111/rest/toscacommander",
    workspace_name="MyWorkspace",
    token="your-token"
)

# Use the API
result = session.get_object("object-id")
result = session.create_object("parent-id", {"TypeName": "Folder", "Name": "New Folder"})

Features

  • Full REST API Support - All TOSCA Commander REST API endpoints
  • Multiple HTTP Clients - Jython, urllib (built-in), requests
  • Python 2/3/Jython Compatible - Works everywhere
  • Pluggable Architecture - Easy to add custom HTTP implementations
  • Comprehensive Logging - Debug, Info, Warning, Error levels
  • 3 Authentication Methods - PAT, Client Credentials, Basic Auth

Installation

# Copy files to your project
cp tosca_commander_api_v2.py /your/project/
cp http_client.py /your/project/

# Or use the original (still works)
cp tosca_commander_api.py /your/project/

Documentation

📚 Full documentation in docs/ directory:

Getting Started

Technical Documentation

Best Practices & Guides

Project Information

HTTP Client Options

# Auto-detection (default) - tries Jython → requests → urllib
api = ToscaCommanderAPI(url, http_client_type='auto')

# urllib (built-in, works everywhere - Python 2/3/Jython)
api = ToscaCommanderAPI(url, http_client_type='urllib')

# requests (faster, better features: pip install requests)
api = ToscaCommanderAPI(url, http_client_type='requests')

# Jython/Java (best for java based environments)
api = ToscaCommanderAPI(url, http_client_type='jython')

Examples

Basic Usage

from tosca_commander_api_v2 import ToscaCommanderAPI

api = ToscaCommanderAPI("http://localhost:1111/rest/toscacommander")
api.set_personal_access_token("your-token")

# Get workspaces
result = api.get_workspaces()

# Open workspace
result = api.open_workspace("MyWorkspace")

Create and Manage Objects

# Create folder
folder = {
    "TypeName": "Folder",
    "Name": "API Test",
    "Properties": {"Description": "Created via API"}
}
result = session.create_object("parent-id", folder)

# Update object
result = session.update_object("object-id", {
    "Properties": {"Description": "Updated"}
})

# Execute task
result = session.execute_task("object-id", "TaskName", {})

Testing

# Test structure (Python 3)
python3 test_structure.py

# Test compatibility
python3 test_compatibility.py

# Test HTTP clients
python3 test_http_clients.py

# Full tests (requires Jython)
jython test_api.py

Compatibility

Feature Python 2.7 Python 3.x Jython 2.7+
Import & Config
urllib HTTP
requests HTTP
Jython HTTP
Logging

Authentication

Personal Access Token (Recommended)

api.set_personal_access_token("your-token")

Client Credentials

api.set_client_credentials("client-id", "client-secret")

Basic Authentication

api.set_basic_auth("username", "password")

Project Structure

tosca-commander-api/
├── tosca_commander_api.py        # Original API (v1.1)
├── tosca_commander_api_v2.py     # Refactored API (v2.0)
├── http_client.py                # HTTP abstraction layer
├── example_usage.py              # Basic examples
├── example_advanced.py           # Advanced examples
├── config.example.py             # Configuration template
├── test_*.py                     # Test suites
├── docs/                         # 📚 Documentation
│   ├── *.md                      # All documentation files
│   └── tricentis_api_docs/       # Tricentis HTML docs (gitignored)
└── README.md                     # This file

Configuration

# Copy config template
cp config.example.py config.py

# Edit with your credentials
nano config.py

Important: Never commit config.py - it's already in .gitignore

Requirements

Minimal (works out of the box):

  • Python 2.7+ or Python 3.x or Jython 2.7+
  • No external dependencies required (uses built-in urllib)

Optional (for better performance):

  • requests library: pip install requests

For Jython integration:

  • Jython 2.7+ with Java libraries

Version

Current: v2.0.0 (with HTTP client abstraction)

  • v2.0.0 - HTTP client abstraction layer
  • v1.1.0 - Python 2/3/Jython compatibility
  • v1.0.0 - Initial release

See CHANGELOG.md for full history.

License

WTFPL - Do What The Fuck You Want To Public License

See LICENSE file for details.

Support

  • 📖 Documentation: docs/
  • 🐛 Issues: Check BEST_PRACTICES.md
  • 💡 Examples: See example_usage.py and example_advanced.py

Credits

Based on TOSCA Commander REST API Documentation v2024.2


Ready to use! 🚀 Start with docs/QUICKSTART.md

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages