infrahub-sdk) provides a comprehensive, type-safe interface to interact with Infrahub’s GraphQL API and manage your infrastructure data programmatically.
Overview
The Python SDK enables you to:- Query and manage objects: Create, read, update, and delete nodes in your infrastructure graph
- Work with schemas: Load and validate schema definitions dynamically
- Manage branches: Create and work with Git-like branches for your infrastructure data
- Handle relationships: Define and traverse complex relationships between infrastructure components
- Execute batch operations: Perform bulk operations efficiently
- Use async/await: Built with modern async Python for optimal performance
Key Features
Type Safety
Full type hints and Pydantic models ensure type safety across your codebase.
Async First
Built with async/await for high-performance concurrent operations.
GraphQL Integration
Seamlessly work with Infrahub’s GraphQL API without writing queries manually.
Schema Management
Dynamically load and validate schemas for your infrastructure models.
Architecture
The SDK is structured around key components:InfrahubClient
The main client class providing access to all SDK functionality:Node Objects
Represent infrastructure objects with attributes and relationships:Schema Management
Manage and validate your infrastructure schema:Branch Operations
Work with Git-like branches:Python Version Support
The SDK requires Python 3.12 or higher.Key Dependencies
The SDK is built on top of:- Pydantic 2.x: Data validation and settings management
- httpx: Modern async HTTP client
- GraphQL: For API communication
- Rich: Enhanced terminal output
Use Cases
Infrastructure Automation
Automate infrastructure provisioning and configuration:Data Migration
Migrate infrastructure data between systems:Reporting & Analytics
Query and analyze infrastructure data:Testing & Validation
Validate infrastructure configurations:Next Steps
Installation
Install the SDK and configure your environment
Quickstart
Get started with your first SDK application
Client Setup
Configure the client for your environment
Querying Data
Learn how to query infrastructure objects