Add TaskStage API support with models, resource, tests and examples#148
Add TaskStage API support with models, resource, tests and examples#148TanyaSingh369-svg wants to merge 16 commits into
Conversation
|
|
||
| stage: Stage = Field(..., alias="stage") | ||
|
|
||
| status: TaskStageStatus = Field( |
There was a problem hiding this comment.
Currently most of attributes at TaskStage were mandatory, Could make id as only mandatory attribute in the TaskStage. So, the model will be utilized as Stub in relationship for other models.
There was a problem hiding this comment.
Updated TaskStage model so only id is required and remaining fields are optional for relationship stub usage.
| # Read | ||
| def read(self, task_stage_id: str) -> TaskStage: | ||
| if not valid_string_id(task_stage_id): | ||
| raise ValueError("Invalid task_stage_id") |
There was a problem hiding this comment.
Create an error InvalidTaskStageID in the errors.py
There was a problem hiding this comment.
Added InvalidTaskStageIDError in errors.py.
| TaskStage.model_rebuild( | ||
| raise_errors=False, | ||
| _types_namespace={ | ||
| "TaskResult": TaskResult, |
There was a problem hiding this comment.
Run model was missed out at the model_rebuild
There was a problem hiding this comment.
Added Run to TaskStage.model_rebuild() namespace.
|
Is this still open to merge for the release ? or else we can close this. @TanyaSingh369-svg |
Description
This PR adds support for Task Stages APIs in the Python TFE client, aligned with the go-tfe implementation.
Task stages represent different phases of a Terraform run and capture execution status, policy checks, and run task results. This PR enables users to retrieve a task stage by ID, list task stages for a run, and override a task stage when permitted.
The implementation follows existing repository patterns for resources and models, and includes proper handling of relationships and forward references between TaskStage, TaskResult, and PolicyEvaluation to avoid circular dependencies.
Changes
- Stage
- TaskStageStatus
- TaskStageStatusTimestamps
- Permissions
- Actions
- TaskResultStatus
- TaskResultStatusTimestamps
- TaskEnforcementLevel
Testing
- Verified service availability on the client
- Verified method presence (read, list, override)
- Tested validation for invalid inputs (e.g., missing or invalid IDs)
- Mocked HTTP transport layer to validate request construction and payloads
- Verified override behavior with and without optional comment
- All unit tests pass successfully (pytest)
- Code formatting and linting checks pass (ruff, mypy)
- Successfully retrieved task stage details via read()
- Verified response fields and structure match expected API output
Output
Run the unit test

Run the examples