Skip to content

Conversation

@KshitijaChoudhari
Copy link
Collaborator

feat(resources): add workspace resources and workspace run tasks functionality
PR Description:
This PR implements comprehensive workspace resources and workspace run tasks functionality for the python-tfe library, providing full CRUD operations for both features with complete HCP Terraform API compatibility.
Motivation and Context:
The python-tfe library was missing workspace resources and workspace run tasks functionality that exists in the Go tfe library. These features are essential for:
Workspace Resources: Listing and managing Terraform resources within workspaces
Workspace Run Tasks: Managing run task associations at the workspace level with full lifecycle operations
This implementation brings feature parity with the Go library and enables Python users to fully manage workspace-level resources and run task configurations.
Type of Change:
New feature (non-breaking change which adds functionality)
Changes Made
Change 1: Workspace Resources Implementation
Added complete workspace resources service with list operations
Implemented proper URL encoding and parameter handling for workspace IDs
Added pagination support with comprehensive filtering options
Created robust data models with Pydantic validation
Change 2: Workspace Run Tasks Implementation
Implemented full CRUD operations (create, read, update, delete, list)
Added stage enum conversion handling (snake_case ↔️ kebab-case) for API compatibility
Created comprehensive options models for all operations
Implemented proper relationship handling and include options
Change 3: Enhanced Run Task Integration
Updated existing run task service to support workspace task relationships
Added graceful Stage enum parsing for API responses
Improved error handling and validation across all operations
Change 4: Comprehensive Testing Suite
Added 36 new unit tests covering all functionality
Implemented comprehensive error scenario testing
Added model validation and data transformation tests
Maintained 100% test coverage for new functionality
Change 5: Example Applications
Created working example files with CLI interfaces
Demonstrated real-world usage with live HCP Terraform integration
Added comprehensive command-line argument handling
Architecture Changes
Service Layer: Added WorkspaceResourcesService and WorkspaceRunTasksService following existing patterns
Model Layer: Created comprehensive Pydantic models with proper validation and field aliases
HTTP Transport: Enhanced URL construction and parameter handling for workspace-specific endpoints
Enum Handling: Implemented bidirectional Stage enum conversion for API compatibility
Key Files Changed:
workspace_resources.py
workspace_run_tasks.py
run_task.py
workspace_resource.py
workspace_run_task.py
init.py
test_workspace_resources.py
test_workspace_run_tasks.py
workspace_resources.py
workspace_run_tasks.py
Testing:
Unit Test Results:
365 total tests passing (100% success rate)
36 new tests added for workspace functionality
0.51 seconds execution time - excellent performance
Zero regressions - all existing functionality maintained
Integration Testing:
Real API Testing: Successfully tested against live HCP Terraform instance
Verified proper parsing of real API responses
Comprehensive error handling validation
Code Quality:
All 132 files properly formatted (Ruff)
Linting: Zero linting issues (Ruff + MyPy)
Type Safety: All 81 source files pass type checking
Standards: Full compliance with project coding standards
Example Application Results:
Workspace Run Tasks: Complete CLI interface with all CRUD
No modifications to existing public APIs
All existing tests continue to pass without modification
Additional Notes
Key Technical Achievements:
Perfect API Compatibility: Implements proper Stage enum =
Robust Error Handling: Comprehensive validation and graceful error scenarios
Production Ready: Real-world testing with live HCP Terraform integration
This implementation provides production-ready workspace resources and workspace run tasks functionality with comprehensive testing, perfect code quality, and full API compatibility.

…tionality

- Add comprehensive workspace resources service with list operations
- Implement full CRUD workspace run tasks service
- Add stage enum conversion handling (snake_case ↔ kebab-case)
- Create complete data models with Pydantic validation
- Add 36 comprehensive unit tests with 100% coverage
- Include working example applications with CLI interfaces
- Maintain backward compatibility with existing pagination
- Support for all execution stages and enforcement levels
@KshitijaChoudhari KshitijaChoudhari requested a review from a team as a code owner November 28, 2025 07:21
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Nov 28, 2025

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@KshitijaChoudhari KshitijaChoudhari deleted the kshitija/WorkspaceRunTasksAndWorkspaceResources branch November 28, 2025 07:21
@KshitijaChoudhari KshitijaChoudhari restored the kshitija/WorkspaceRunTasksAndWorkspaceResources branch November 28, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant