Skip to content

Commit 40471ee

Browse files
fix: add missing exports to __all__ and fix linting issues
- Add all new run tasks integration models to __all__ exports - Fix trailing whitespace issues across multiple files - Run ruff format to ensure consistent code style - All 22 unit tests passing - All linting checks pass
1 parent 41f5977 commit 40471ee

6 files changed

Lines changed: 165 additions & 179 deletions

File tree

src/pytfe/models/__init__.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -258,23 +258,6 @@
258258
RunTaskRequest,
259259
RunTaskRequestCapabilities,
260260
)
261-
from .task_result import (
262-
TaskEnforcementLevel,
263-
TaskResult,
264-
TaskResultStatus,
265-
TaskResultStatusTimestamps,
266-
)
267-
from .task_stages import (
268-
Actions,
269-
Permissions,
270-
Stage,
271-
TaskStage,
272-
TaskStageListOptions,
273-
TaskStageOverrideOptions,
274-
TaskStageReadOptions,
275-
TaskStageStatus,
276-
TaskStageStatusTimestamps,
277-
)
278261
from .run_trigger import (
279262
RunTrigger,
280263
RunTriggerCreateOptions,
@@ -293,6 +276,23 @@
293276
SSHKeyListOptions,
294277
SSHKeyUpdateOptions,
295278
)
279+
from .task_result import (
280+
TaskEnforcementLevel,
281+
TaskResult,
282+
TaskResultStatus,
283+
TaskResultStatusTimestamps,
284+
)
285+
from .task_stages import (
286+
Actions,
287+
Permissions,
288+
Stage,
289+
TaskStage,
290+
TaskStageListOptions,
291+
TaskStageOverrideOptions,
292+
TaskStageReadOptions,
293+
TaskStageStatus,
294+
TaskStageStatusTimestamps,
295+
)
296296

297297
# Variables
298298
from .variable import (
@@ -556,6 +556,19 @@
556556
"RunTaskCreateOptions",
557557
"RunTaskUpdateOptions",
558558
"RunTaskReadOptions",
559+
"RunTaskRequest",
560+
"RunTaskRequestCapabilities",
561+
"TaskResult",
562+
"TaskResultStatus",
563+
"TaskResultStatusTimestamps",
564+
"Actions",
565+
"Permissions",
566+
"TaskStage",
567+
"TaskStageListOptions",
568+
"TaskStageOverrideOptions",
569+
"TaskStageReadOptions",
570+
"TaskStageStatus",
571+
"TaskStageStatusTimestamps",
559572
# Run triggers
560573
"RunTrigger",
561574
"RunTriggerCreateOptions",

src/pytfe/models/run_task_request.py

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ class RunTaskRequestCapabilities(BaseModel):
1515
"""Capabilities that the caller supports."""
1616

1717
outcomes: bool = Field(
18-
default=False,
19-
description="Whether the run task server supports outcomes"
18+
default=False, description="Whether the run task server supports outcomes"
2019
)
21-
20+
2221
model_config = ConfigDict(populate_by_name=True)
2322

2423

2524
class RunTaskRequest(BaseModel):
2625
"""Represents the payload that TFC/TFE sends to a run task's URL.
27-
26+
2827
This is the incoming request that your external run task server receives
2928
from Terraform Cloud/Enterprise when a run task is triggered.
30-
29+
3130
API Documentation:
3231
https://developer.hashicorp.com/terraform/enterprise/api-docs/run-tasks/run-tasks-integration#common-properties
3332
"""
@@ -36,45 +35,26 @@ class RunTaskRequest(BaseModel):
3635
description="Token to use for authentication when sending callback"
3736
)
3837
capabilities: RunTaskRequestCapabilities | None = Field(
39-
default=None,
40-
description="Capabilities that the caller supports"
38+
default=None, description="Capabilities that the caller supports"
4139
)
4240
configuration_version_download_url: str | None = Field(
43-
default=None,
44-
description="URL to download the configuration version"
41+
default=None, description="URL to download the configuration version"
4542
)
4643
configuration_version_id: str | None = Field(
47-
default=None,
48-
description="ID of the configuration version"
49-
)
50-
is_speculative: bool = Field(
51-
description="Whether this is a speculative run"
52-
)
53-
organization_name: str = Field(
54-
description="Name of the organization"
55-
)
56-
payload_version: int = Field(
57-
description="Version of the payload format"
44+
default=None, description="ID of the configuration version"
5845
)
46+
is_speculative: bool = Field(description="Whether this is a speculative run")
47+
organization_name: str = Field(description="Name of the organization")
48+
payload_version: int = Field(description="Version of the payload format")
5949
plan_json_api_url: str | None = Field(
6050
default=None,
61-
description="URL to access the plan JSON via API (post_plan, pre_apply, post_apply stages)"
62-
)
63-
run_app_url: str = Field(
64-
description="URL to view the run in TFC/TFE UI"
65-
)
66-
run_created_at: datetime = Field(
67-
description="Timestamp when the run was created"
68-
)
69-
run_created_by: str = Field(
70-
description="Username of the user who created the run"
71-
)
72-
run_id: str = Field(
73-
description="ID of the run"
74-
)
75-
run_message: str = Field(
76-
description="Message associated with the run"
51+
description="URL to access the plan JSON via API (post_plan, pre_apply, post_apply stages)",
7752
)
53+
run_app_url: str = Field(description="URL to view the run in TFC/TFE UI")
54+
run_created_at: datetime = Field(description="Timestamp when the run was created")
55+
run_created_by: str = Field(description="Username of the user who created the run")
56+
run_id: str = Field(description="ID of the run")
57+
run_message: str = Field(description="Message associated with the run")
7858
stage: str = Field(
7959
description="Stage when the run task is executed (pre_plan, post_plan, pre_apply, post_apply)"
8060
)
@@ -84,37 +64,24 @@ class RunTaskRequest(BaseModel):
8464
task_result_enforcement_level: str = Field(
8565
description="Enforcement level for the task result (advisory, mandatory)"
8666
)
87-
task_result_id: str = Field(
88-
description="ID of the task result"
89-
)
90-
vcs_branch: str | None = Field(
91-
default=None,
92-
description="VCS branch name"
93-
)
67+
task_result_id: str = Field(description="ID of the task result")
68+
vcs_branch: str | None = Field(default=None, description="VCS branch name")
9469
vcs_commit_url: str | None = Field(
95-
default=None,
96-
description="URL to the VCS commit"
70+
default=None, description="URL to the VCS commit"
9771
)
9872
vcs_pull_request_url: str | None = Field(
99-
default=None,
100-
description="URL to the VCS pull request"
73+
default=None, description="URL to the VCS pull request"
10174
)
10275
vcs_repo_url: str | None = Field(
103-
default=None,
104-
description="URL to the VCS repository"
76+
default=None, description="URL to the VCS repository"
10577
)
10678
workspace_app_url: str = Field(
10779
description="URL to view the workspace in TFC/TFE UI"
10880
)
109-
workspace_id: str = Field(
110-
description="ID of the workspace"
111-
)
112-
workspace_name: str = Field(
113-
description="Name of the workspace"
114-
)
81+
workspace_id: str = Field(description="ID of the workspace")
82+
workspace_name: str = Field(description="Name of the workspace")
11583
workspace_working_directory: str | None = Field(
116-
default=None,
117-
description="Working directory for the workspace"
84+
default=None, description="Working directory for the workspace"
11885
)
11986

12087
model_config = ConfigDict(populate_by_name=True)

src/pytfe/models/task_result.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class TaskResultStatus(str, Enum):
1919
"""Task result status enum."""
20-
20+
2121
PASSED = "passed"
2222
FAILED = "failed"
2323
PENDING = "pending"
@@ -28,30 +28,30 @@ class TaskResultStatus(str, Enum):
2828

2929
class TaskEnforcementLevel(str, Enum):
3030
"""Task enforcement level enum."""
31-
31+
3232
ADVISORY = "advisory"
3333
MANDATORY = "mandatory"
3434

3535

3636
class TaskResultStatusTimestamps(BaseModel):
3737
"""Timestamps recorded for a task result."""
38-
38+
3939
errored_at: datetime | None = Field(default=None, alias="errored-at")
4040
running_at: datetime | None = Field(default=None, alias="running-at")
4141
canceled_at: datetime | None = Field(default=None, alias="canceled-at")
4242
failed_at: datetime | None = Field(default=None, alias="failed-at")
4343
passed_at: datetime | None = Field(default=None, alias="passed-at")
44-
44+
4545
model_config = ConfigDict(populate_by_name=True)
4646

4747

4848
class TaskResult(BaseModel):
4949
"""Represents a HCP Terraform or Terraform Enterprise run task result.
50-
50+
5151
API Documentation:
5252
https://developer.hashicorp.com/terraform/cloud-docs/api-docs/task-results
5353
"""
54-
54+
5555
id: str
5656
status: TaskResultStatus
5757
message: str
@@ -67,8 +67,8 @@ class TaskResult(BaseModel):
6767
alias="workspace-task-enforcement-level"
6868
)
6969
agent_pool_id: str | None = Field(default=None, alias="agent-pool-id")
70-
70+
7171
# Relationships
7272
task_stage: TaskStage | None = Field(default=None, alias="task-stage")
73-
73+
7474
model_config = ConfigDict(populate_by_name=True)

src/pytfe/models/task_stages.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class Stage(str, Enum):
2121
"""Enum representing possible run stages for run tasks."""
22-
22+
2323
PRE_PLAN = "pre-plan"
2424
POST_PLAN = "post-plan"
2525
PRE_APPLY = "pre-apply"
@@ -28,7 +28,7 @@ class Stage(str, Enum):
2828

2929
class TaskStageStatus(str, Enum):
3030
"""Enum representing all possible statuses for a task stage."""
31-
31+
3232
PENDING = "pending"
3333
RUNNING = "running"
3434
PASSED = "passed"
@@ -41,43 +41,43 @@ class TaskStageStatus(str, Enum):
4141

4242
class Permissions(BaseModel):
4343
"""Permission types for overriding a task stage."""
44-
44+
4545
can_override_policy: bool | None = Field(default=None, alias="can-override-policy")
4646
can_override_tasks: bool | None = Field(default=None, alias="can-override-tasks")
4747
can_override: bool | None = Field(default=None, alias="can-override")
48-
48+
4949
model_config = ConfigDict(populate_by_name=True)
5050

5151

5252
class Actions(BaseModel):
5353
"""Task stage actions."""
54-
54+
5555
is_overridable: bool | None = Field(default=None, alias="is-overridable")
56-
56+
5757
model_config = ConfigDict(populate_by_name=True)
5858

5959

6060
class TaskStageStatusTimestamps(BaseModel):
6161
"""Timestamps recorded for a task stage."""
62-
62+
6363
errored_at: datetime | None = Field(default=None, alias="errored-at")
6464
running_at: datetime | None = Field(default=None, alias="running-at")
6565
canceled_at: datetime | None = Field(default=None, alias="canceled-at")
6666
failed_at: datetime | None = Field(default=None, alias="failed-at")
6767
passed_at: datetime | None = Field(default=None, alias="passed-at")
68-
68+
6969
model_config = ConfigDict(populate_by_name=True)
7070

7171

7272
class TaskStage(BaseModel):
7373
"""Represents a HCP Terraform or Terraform Enterprise run's task stage.
74-
74+
7575
Task stages are where run tasks can occur during a run lifecycle.
76-
76+
7777
API Documentation:
7878
https://developer.hashicorp.com/terraform/cloud-docs/api-docs/task-stages
7979
"""
80-
80+
8181
id: str
8282
stage: Stage
8383
status: TaskStageStatus
@@ -86,34 +86,33 @@ class TaskStage(BaseModel):
8686
updated_at: datetime = Field(alias="updated-at")
8787
permissions: Permissions | None = None
8888
actions: Actions | None = None
89-
89+
9090
# Relationships
9191
run: Run | None = None
9292
task_results: list[TaskResult] = Field(default_factory=list, alias="task-results")
9393
policy_evaluations: list[PolicyEvaluation] = Field(
94-
default_factory=list,
95-
alias="policy-evaluations"
94+
default_factory=list, alias="policy-evaluations"
9695
)
97-
96+
9897
model_config = ConfigDict(populate_by_name=True)
9998

10099

101100
class TaskStageOverrideOptions(BaseModel):
102101
"""Options for overriding a task stage."""
103-
102+
104103
comment: str | None = None
105104

106105

107106
class TaskStageReadOptions(BaseModel):
108107
"""Options for reading a task stage."""
109-
108+
110109
include: list[str] | None = None
111110

112111

113112
class TaskStageListOptions(BaseModel):
114113
"""Options for listing task stages."""
115-
114+
116115
page_number: int | None = Field(default=None, alias="page[number]")
117116
page_size: int | None = Field(default=None, alias="page[size]")
118-
117+
119118
model_config = ConfigDict(populate_by_name=True)

0 commit comments

Comments
 (0)