Skip to content

Commit 4f42437

Browse files
feat: add domain API architecture with lazy loading namespaces
- Add new domain_api module with base namespace system - Add lazy loading mechanism for domain namespaces - Update client to support both legacy and domain API modes
1 parent 023f884 commit 4f42437

File tree

63 files changed

+13803
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+13803
-5
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python3
2+
"""Demo script for the ConnectionsNamespace domain API.
3+
4+
This script demonstrates how to use the new Connections domain namespace
5+
to manage cloud storage connections in Kili projects.
6+
7+
Note: This is a demonstration script. In real usage, you would need:
8+
- Valid API credentials
9+
- Existing cloud storage integrations
10+
- Valid project IDs
11+
"""
12+
13+
14+
def demo_connections_namespace():
15+
"""Demonstrate the Connections domain namespace functionality."""
16+
print("🔗 Kili ConnectionsNamespace Demo")
17+
print("=" * 50)
18+
19+
# Initialize Kili client (would need real API key in practice)
20+
print("\n1. Initializing Kili client...")
21+
# kili = Kili(api_key="your-api-key-here")
22+
23+
# For demo purposes, we'll show the API structure
24+
print(" ✓ Client initialized with connections namespace available")
25+
print(" Access via: kili.connections or kili.connections (in non-legacy mode)")
26+
27+
print("\n2. Available Operations:")
28+
print(" 📋 list() - Query and list cloud storage connections")
29+
print(" ➕ add() - Connect cloud storage integration to project")
30+
print(" 🔄 sync() - Synchronize connection with cloud storage")
31+
32+
print("\n3. Example Usage Patterns:")
33+
34+
print("\n 📋 List connections for a project:")
35+
print(" ```python")
36+
print(" connections = kili.connections.list(project_id='project_123')")
37+
print(" print(f'Found {len(connections)} connections')")
38+
print(" ```")
39+
40+
print("\n ➕ Add a new connection with filtering:")
41+
print(" ```python")
42+
print(" result = kili.connections.add(")
43+
print(" project_id='project_123',")
44+
print(" cloud_storage_integration_id='integration_456',")
45+
print(" prefix='data/images/',")
46+
print(" include=['*.jpg', '*.png'],")
47+
print(" exclude=['**/temp/*']")
48+
print(" )")
49+
print(" connection_id = result['id']")
50+
print(" ```")
51+
52+
print("\n 🔄 Synchronize connection (with dry-run preview):")
53+
print(" ```python")
54+
print(" # Preview changes first")
55+
print(" preview = kili.connections.sync(")
56+
print(" connection_id='connection_789',")
57+
print(" dry_run=True")
58+
print(" )")
59+
print(" ")
60+
print(" # Apply changes")
61+
print(" result = kili.connections.sync(")
62+
print(" connection_id='connection_789',")
63+
print(" delete_extraneous_files=False")
64+
print(" )")
65+
print(" print(f'Synchronized {result[\"numberOfAssets\"]} assets')")
66+
print(" ```")
67+
68+
print("\n4. Key Features:")
69+
print(" 🎯 Simplified API focused on connections (vs general cloud storage)")
70+
print(" 🛡️ Enhanced error handling with user-friendly messages")
71+
print(" ✅ Input validation for required parameters")
72+
print(" 📊 Comprehensive type hints and documentation")
73+
print(" 🔄 Lazy loading and memory optimizations via base class")
74+
print(" 🧪 Dry-run support for safe synchronization testing")
75+
76+
print("\n5. Integration Benefits:")
77+
print(" • Clean separation: connections vs cloud storage integrations")
78+
print(" • Consistent API patterns across all domain namespaces")
79+
print(" • Better discoverability through focused namespace")
80+
print(" • Enhanced user experience for cloud storage workflows")
81+
82+
print("\n✨ ConnectionsNamespace Demo Complete!")
83+
print("=" * 50)
84+
85+
86+
if __name__ == "__main__":
87+
demo_connections_namespace()

0 commit comments

Comments
 (0)