The Kubiya Sources service provides a powerful interface for managing tool sources and repositories through the Kubiya platform.
It enables you to discover, add, update, and monitor tool sources with support for both Git repositories and inline tool definitions.
from kubiya_workflow_sdk import KubiyaClientfrom kubiya_workflow_sdk.kubiya_services.exceptions import SourceError# Initialize clientclient = KubiyaClient( api_key="your-api-key", base_url="https://api.kubiya.ai")try: # List all sources sources = client.sources.list() print(f"Found {len(sources)} sources") # List with full metadata (slower but comprehensive) sources_with_metadata = client.sources.list(full=True, max_concurrent=5) for source in sources_with_metadata: print(f"Source: {source.get('name')} ({source.get('type')})") print(f"Tools: {len(source.get('tools', []))}") print(f"UUID: {source.get('uuid')}")except SourceError as e: print(f"Failed to list sources: {e}")
# Get source UUID from previous operationssource_uuid = "your-source-uuid"try: # Add a new tool to existing inline source client.sources.inline.add( source_uuid=source_uuid, name="new-tool", description="A new tool", type="docker", image="python:3.9", content="print('Hello from Python!')", arg=["input:string:Input message:true"] ) # List all tools in the source tools = client.sources.inline.list(source_uuid) print(f"Inline tools: {len(tools)}") # Update a specific tool client.sources.inline.update( source_uuid=source_uuid, tool_name="new-tool", file="./updated-tool.yaml" ) # Delete a tool client.sources.inline.delete(source_uuid, "old-tool")except SourceError as e: print(f"Inline tool operation failed: {e}")
# Use appropriate concurrency for metadata fetchingsources = client.sources.list( full=True, max_concurrent=10, # Balance between speed and API limits debug=True # Enable debug logging for troubleshooting)
# Scan first to validate sourcetry: scan_result = client.sources.scan(source_url) if scan_result.get('scan_successful'): print(f"Found {len(scan_result.get('tools', []))} tools") # Now add the source result = client.sources.add(source_url=source_url, name="Validated Source") else: print("Source scan failed, not adding")except SourceError as e: print(f"Validation failed: {e}")
# Regular health checksfor source in client.sources.list(): try: debug_info = client.sources.debug(source['uuid'], output="json") # Parse debug info and check for issues if 'metadata_error' in debug_info: print(f"⚠️ Source {source['name']} has metadata issues") except SourceError: print(f"❌ Source {source['name']} is not accessible")