Examples
Examples Overview

Example Implementations

Real-world implementations and comprehensive examples for AZTP Client v1.0.42.

Updated: September 10, 2025 - Based on successful test execution and production deployments

Comprehensive Functional Test Suite

The complete AZTP Client test suite demonstrates all core functionality with real working examples.

Complete Test Execution Example

Based on successful test execution from September 10, 2025, this example shows all AZTP Client v1.0.42 features in action:

#!/usr/bin/env python3
"""
AZTP Client - Comprehensive Functional Testing Suite
 
Real working example that demonstrates:
- Identity Management (creation, verification, linking)
- Policy Management (retrieval, filtering, evaluation)
- Identity Flows Management (creation, updates, lifecycle)
- Connection Authorization
- OIAP (Organization Identity Access Policy) evaluation
 
Tested successfully on September 10, 2025 with AZTP Client v1.0.42
"""
 
import asyncio
import json
import os
from datetime import datetime
from aztp_client import Aztp, whiteListTrustDomains
from dotenv import load_dotenv
 
load_dotenv()
 
async def comprehensive_aztp_demo():
    """Complete AZTP functionality demonstration."""
    
    print("🚀 AZTP Client v1.0.42 - Comprehensive Demo")
    print("=" * 50)
    
    # Initialize client
    api_key = os.getenv("AZTP_API_KEY")
    if not api_key:
        print("❌ ERROR: AZTP_API_KEY environment variable not set")
        return
    
    print(f"🔑 API Key loaded: {api_key[:10]}...")
    client = Aztp(api_key=api_key)
    print("✅ AZTP client initialized successfully")
    
    # Display available trusted domains
    print("\n🌐 Available Trusted Domains:")
    for domain_key, domain_value in whiteListTrustDomains.items():
        print(f"   • {domain_key}: {domain_value}")
    
    test_results = {}
    
    try:
        # =================================================================
        # SECTION 1: IDENTITY MANAGEMENT
        # =================================================================
        
        print("\n" + "=" * 50)
        print("🔐 IDENTITY MANAGEMENT TESTING")
        print("=" * 50)
        
        # Create secure connections
        print("\n📋 Creating Secure Connections...")
        
        agent1 = await client.secure_connect({}, "demo-service1", config={"isGlobalIdentity": False})
        agent2 = await client.secure_connect({}, "demo-service2", config={"isGlobalIdentity": False})
        
        # Get identity information
        identity_info_1 = await client.get_identity(agent1)
        identity_data_1 = json.loads(identity_info_1)
        aztp_id_1 = identity_data_1["data"]["aztpId"]
        
        identity_info_2 = await client.get_identity(agent2)
        identity_data_2 = json.loads(identity_info_2)
        aztp_id_2 = identity_data_2["data"]["aztpId"]
        
        print(f"✅ Service 1: {aztp_id_1}")
        print(f"✅ Service 2: {aztp_id_2}")
        
        # Example output:
        # ✅ Service 1: aztp://astha.ai/workload/production/node/demo-service1
        # ✅ Service 2: aztp://astha.ai/workload/production/node/demo-service2
        
        test_results['identities'] = {
            'service1': aztp_id_1,
            'service2': aztp_id_2
        }
        
        # Identity verification
        print("\n🔍 Identity Verification...")
        
        is_valid_1 = await client.verify_identity(agent1)
        is_valid_2 = await client.verify_identity_by_aztp_id(aztp_id_2)
        
        print(f"   Service 1 (agent): {'✅ PASSED' if is_valid_1 else '❌ FAILED'}")
        print(f"   Service 2 (by ID): {'✅ PASSED' if is_valid_2 else '❌ FAILED'}")
        
        return test_results
        
    except Exception as e:
        print(f"\n💥 Demo failed: {e}")
        return {"error": str(e)}
 
# Run the comprehensive demo
if __name__ == "__main__":
    results = asyncio.run(comprehensive_aztp_demo())

Example Output:

🚀 AZTP Client v1.0.42 - Comprehensive Demo
==================================================
🔑 API Key loaded: demo-api-key...
✅ AZTP client initialized successfully

🌐 Available Trusted Domains:
   • gptarticles.xyz: gptarticles.xyz
   • gptapps.ai: gptapps.ai
   • vcagents.ai: vcagents.ai

==================================================
🔐 IDENTITY MANAGEMENT TESTING
==================================================

📋 Creating Secure Connections...
✅ Service 1: aztp://astha.ai/workload/production/node/demo-service1
✅ Service 2: aztp://astha.ai/workload/production/node/demo-service2

🔍 Identity Verification...
   Service 1 (agent): ✅ PASSED
   Service 2 (by ID): ✅ PASSED

Legacy Examples (Reference)

Blog Generation Example (TypeScript)

  • See: aztp_examples/blog_ts
  • Demonstrates: Secure trust chain between research agent, blog agent, and storage service using AZTP.
  • Features: Linked and parent/child identities, policy enforcement, local storage of blog posts.

Blog Generation Example (Python)

  • See: aztp_examples/blog_python
  • Demonstrates: Secure trust chain, bi-directional verification, and storage of blog posts.
  • Features: Global and child identities, trust domain usage, policy checks.