execution-plane-client 0.1.11__tar.gz → 0.1.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/.gitignore +3 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/PKG-INFO +2 -2
- execution_plane_client-0.1.13/__init__.py +1 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/_version.py +2 -2
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/targets.py +2 -2
- execution_plane_client-0.1.13/models/__init__.py +1 -0
- execution_plane_client-0.1.13/models/cluster.py +67 -0
- execution_plane_client-0.1.13/models/execution_target.py +237 -0
- execution_plane_client-0.1.13/models/shared.py +32 -0
- execution_plane_client-0.1.13/models/work_item.py +81 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/pyproject.toml +3 -3
- execution_plane_client-0.1.11/__init__.py +0 -1
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/LICENSE +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/README.md +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/catalog.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/__init__.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/base.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/clusters.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/control.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/credentials.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/results.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/commands/work.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/errors.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/handlers.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/protocol.py +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/py.typed +0 -0
- {execution_plane_client-0.1.11 → execution_plane_client-0.1.13}/registry.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: execution-plane-client
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: Shared execution-plane command
|
|
3
|
+
Version: 0.1.13
|
|
4
|
+
Summary: Shared execution-plane command, response, and handler contracts
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Requires-Python: <3.15,>=3.12
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shared command, response, and handler contracts."""
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.13'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 13)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -88,7 +88,7 @@ class TargetDefinition(WireModel):
|
|
|
88
88
|
"""Desired execution-target configuration."""
|
|
89
89
|
|
|
90
90
|
name: Annotated[StrictStr, Field(min_length=1, max_length=255)]
|
|
91
|
-
backend_type: Literal["
|
|
91
|
+
backend_type: Literal["kubernetes", "openshell"]
|
|
92
92
|
placement: Placement
|
|
93
93
|
endpoint: Annotated[StrictStr, Field(min_length=1, max_length=2048)]
|
|
94
94
|
credential_ref: UUID
|
|
@@ -103,7 +103,7 @@ class TargetDefinition(WireModel):
|
|
|
103
103
|
@model_validator(mode="after")
|
|
104
104
|
def check_backend(self) -> Self:
|
|
105
105
|
"""Reject backend/placement pairs unsupported by the provider adapters."""
|
|
106
|
-
if (self.backend_type == "
|
|
106
|
+
if (self.backend_type == "kubernetes") != isinstance(self.placement, KubernetesPlacement):
|
|
107
107
|
message = "Backend does not support this placement"
|
|
108
108
|
raise ValueError(message)
|
|
109
109
|
return self
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shared Execution Plane REST resource contracts; import from feature modules."""
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Shared cluster list and response contracts."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
7
|
+
|
|
8
|
+
from execution_plane_client.models.shared import EPListParams, ResourcesResponse
|
|
9
|
+
|
|
10
|
+
# Cluster query metadata - single source of truth for EP and client
|
|
11
|
+
CLUSTER_FILTERABLE_FIELDS = [
|
|
12
|
+
"id",
|
|
13
|
+
"created_at",
|
|
14
|
+
"updated_at",
|
|
15
|
+
"name",
|
|
16
|
+
"endpoint",
|
|
17
|
+
"status",
|
|
18
|
+
"status_message",
|
|
19
|
+
"enabled",
|
|
20
|
+
"is_default",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
CLUSTER_SORTABLE_FIELDS = [
|
|
24
|
+
"id",
|
|
25
|
+
"created_at",
|
|
26
|
+
"updated_at",
|
|
27
|
+
"name",
|
|
28
|
+
"endpoint",
|
|
29
|
+
"status",
|
|
30
|
+
"enabled",
|
|
31
|
+
"is_default",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ClusterRead(BaseModel):
|
|
36
|
+
"""Provisioned cluster state, keyed by the actual cluster UUID."""
|
|
37
|
+
|
|
38
|
+
model_config = ConfigDict(from_attributes=True)
|
|
39
|
+
|
|
40
|
+
id: UUID = Field(description="Cluster unique identifier")
|
|
41
|
+
name: str = Field(description="Cluster name")
|
|
42
|
+
endpoint: str = Field(description="Cluster API endpoint URL")
|
|
43
|
+
status: str = Field(description="Cluster lifecycle status")
|
|
44
|
+
status_message: str | None = Field(default=None, description="Human-readable status message or error details")
|
|
45
|
+
enabled: bool = Field(description="Whether the cluster is enabled for use")
|
|
46
|
+
is_default: bool = Field(description="Whether this is the default cluster")
|
|
47
|
+
labels: dict[str, str] = Field(description="Key-value labels for the cluster")
|
|
48
|
+
created_at: datetime = Field(description="Creation timestamp")
|
|
49
|
+
updated_at: datetime = Field(description="Last update timestamp")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ClusterListParams(EPListParams):
|
|
53
|
+
"""Query parameters for listing clusters."""
|
|
54
|
+
|
|
55
|
+
id: str | None = Field(default=None, description="Filter by id")
|
|
56
|
+
name: str | None = Field(default=None, description="Filter by name")
|
|
57
|
+
endpoint: str | None = Field(default=None, description="Filter by endpoint")
|
|
58
|
+
status: str | None = Field(default=None, description="Filter by status")
|
|
59
|
+
status_message: str | None = Field(default=None, description="Filter by status_message")
|
|
60
|
+
enabled: str | None = Field(default=None, description="Filter by enabled")
|
|
61
|
+
is_default: str | None = Field(default=None, description="Filter by is_default")
|
|
62
|
+
created_at: str | None = Field(default=None, description="Filter by created_at")
|
|
63
|
+
updated_at: str | None = Field(default=None, description="Filter by updated_at")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ClusterListResponse(ResourcesResponse[ClusterRead]):
|
|
67
|
+
"""Paginated list response for clusters."""
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"""Shared execution-target list, placement, and response contracts."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Annotated, Literal, Self
|
|
7
|
+
from uuid import UUID
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
10
|
+
from pydantic.json_schema import SkipJsonSchema
|
|
11
|
+
|
|
12
|
+
from execution_plane_client.commands.targets import KubernetesPlacement as CommandKubernetesPlacement
|
|
13
|
+
from execution_plane_client.models.shared import EPListParams, ResourcesResponse
|
|
14
|
+
|
|
15
|
+
_LABEL_NAME = re.compile(r"^[A-Za-z0-9]([A-Za-z0-9_.-]*[A-Za-z0-9])?$")
|
|
16
|
+
_DNS_LABEL = re.compile(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
|
|
17
|
+
_TOLERATION_EFFECTS = {"", "NoSchedule", "PreferNoSchedule", "NoExecute"}
|
|
18
|
+
_MAX_LABEL_NAME_LENGTH = 63
|
|
19
|
+
_MAX_DNS_SUBDOMAIN_LENGTH = 253
|
|
20
|
+
|
|
21
|
+
# Execution target query metadata - single source of truth for EP and client
|
|
22
|
+
EXECUTION_TARGET_FILTERABLE_FIELDS = [
|
|
23
|
+
"id",
|
|
24
|
+
"created_at",
|
|
25
|
+
"name",
|
|
26
|
+
"endpoint",
|
|
27
|
+
"status",
|
|
28
|
+
"backend_type",
|
|
29
|
+
"cluster_id",
|
|
30
|
+
"enabled",
|
|
31
|
+
"is_default",
|
|
32
|
+
"last_ran_at",
|
|
33
|
+
"status_message",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
EXECUTION_TARGET_SORTABLE_FIELDS = [
|
|
37
|
+
"id",
|
|
38
|
+
"created_at",
|
|
39
|
+
"name",
|
|
40
|
+
"endpoint",
|
|
41
|
+
"status",
|
|
42
|
+
"backend_type",
|
|
43
|
+
"cluster_id",
|
|
44
|
+
"enabled",
|
|
45
|
+
"is_default",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class BackendType(StrEnum):
|
|
50
|
+
"""Supported execution target backends."""
|
|
51
|
+
|
|
52
|
+
KUBERNETES = "kubernetes"
|
|
53
|
+
OPENSHELL = "openshell"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class TargetStatus(StrEnum):
|
|
57
|
+
"""Lifecycle states of an execution target."""
|
|
58
|
+
|
|
59
|
+
REGISTERING = "registering"
|
|
60
|
+
VALIDATING = "validating"
|
|
61
|
+
BOOTSTRAPPING = "bootstrapping"
|
|
62
|
+
ACTIVE = "active"
|
|
63
|
+
DEGRADED = "degraded"
|
|
64
|
+
DRAINING = "draining"
|
|
65
|
+
FAILED = "failed"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _is_valid_label_key(value: str) -> bool:
|
|
69
|
+
"""Return whether a value uses Kubernetes label-key syntax."""
|
|
70
|
+
prefix, separator, name = value.partition("/")
|
|
71
|
+
if separator:
|
|
72
|
+
prefix_labels = prefix.split(".")
|
|
73
|
+
if (
|
|
74
|
+
not prefix
|
|
75
|
+
or len(prefix) > _MAX_DNS_SUBDOMAIN_LENGTH
|
|
76
|
+
or any(len(label) > _MAX_LABEL_NAME_LENGTH or not _DNS_LABEL.fullmatch(label) for label in prefix_labels)
|
|
77
|
+
):
|
|
78
|
+
return False
|
|
79
|
+
else:
|
|
80
|
+
name = prefix
|
|
81
|
+
return len(name) <= _MAX_LABEL_NAME_LENGTH and bool(_LABEL_NAME.fullmatch(name))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _is_valid_label_value(value: str) -> bool:
|
|
85
|
+
"""Return whether a value uses Kubernetes label-value syntax."""
|
|
86
|
+
return len(value) <= _MAX_LABEL_NAME_LENGTH and (value == "" or bool(_LABEL_NAME.fullmatch(value)))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class KubernetesPlacement(BaseModel):
|
|
90
|
+
"""Metadata required to place workers on Kubernetes."""
|
|
91
|
+
|
|
92
|
+
type: Literal["kubernetes"] = "kubernetes"
|
|
93
|
+
namespace: str = Field(
|
|
94
|
+
min_length=1,
|
|
95
|
+
max_length=63,
|
|
96
|
+
pattern=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
|
|
97
|
+
description="Kubernetes namespace reserved for execution workloads",
|
|
98
|
+
)
|
|
99
|
+
node_selectors: list[str] = Field(default_factory=list)
|
|
100
|
+
tolerations: list[str] = Field(default_factory=list)
|
|
101
|
+
|
|
102
|
+
@field_validator("node_selectors")
|
|
103
|
+
@classmethod
|
|
104
|
+
def validate_node_selectors(cls, values: list[str]) -> list[str]:
|
|
105
|
+
"""Validate compact Kubernetes node-selector expressions."""
|
|
106
|
+
for value in values:
|
|
107
|
+
key, separator, selector_value = value.partition("=")
|
|
108
|
+
if not separator or not _is_valid_label_key(key) or not _is_valid_label_value(selector_value):
|
|
109
|
+
message = "must use a valid Kubernetes label selector in key=value form"
|
|
110
|
+
raise ValueError(message)
|
|
111
|
+
return values
|
|
112
|
+
|
|
113
|
+
@field_validator("tolerations")
|
|
114
|
+
@classmethod
|
|
115
|
+
def validate_tolerations(cls, values: list[str]) -> list[str]:
|
|
116
|
+
"""Validate compact Kubernetes toleration expressions."""
|
|
117
|
+
for value in values:
|
|
118
|
+
key_value, separator, effect = value.rpartition(":")
|
|
119
|
+
if not separator:
|
|
120
|
+
key_value = value
|
|
121
|
+
effect = ""
|
|
122
|
+
key, equals, toleration_value = key_value.partition("=")
|
|
123
|
+
if equals:
|
|
124
|
+
valid_key = bool(key) and _is_valid_label_key(key)
|
|
125
|
+
valid_value = _is_valid_label_value(toleration_value)
|
|
126
|
+
else:
|
|
127
|
+
valid_key = not key or _is_valid_label_key(key)
|
|
128
|
+
valid_value = not toleration_value
|
|
129
|
+
if not valid_key or not valid_value or effect not in _TOLERATION_EFFECTS:
|
|
130
|
+
message = "must use a valid Kubernetes toleration short form"
|
|
131
|
+
raise ValueError(message)
|
|
132
|
+
return values
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class RHELPlacement(BaseModel):
|
|
136
|
+
"""Placeholder for RHEL-specific execution-target metadata."""
|
|
137
|
+
|
|
138
|
+
type: Literal["rhel"] = "rhel"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
ExecutionTargetPlacementTypes = KubernetesPlacement | RHELPlacement
|
|
142
|
+
ExecutionTargetPlacement = Annotated[
|
|
143
|
+
ExecutionTargetPlacementTypes,
|
|
144
|
+
Field(discriminator="type"),
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class ExecutionTargetRead(BaseModel):
|
|
149
|
+
"""Safe execution-target representation without management credentials."""
|
|
150
|
+
|
|
151
|
+
model_config = ConfigDict(from_attributes=True)
|
|
152
|
+
|
|
153
|
+
id: UUID = Field(description="Execution target unique identifier")
|
|
154
|
+
cluster_id: UUID = Field(description="Parent cluster identifier")
|
|
155
|
+
name: str = Field(description="Execution target name")
|
|
156
|
+
backend_type: BackendType = Field(description="Backend execution platform type")
|
|
157
|
+
endpoint: str = Field(description="Execution target API endpoint URL")
|
|
158
|
+
placement: ExecutionTargetPlacement = Field(description="Platform-specific placement configuration")
|
|
159
|
+
status: TargetStatus = Field(description="Execution target lifecycle status")
|
|
160
|
+
enabled: bool = Field(description="Whether the target is enabled for use")
|
|
161
|
+
is_default: bool = Field(description="Whether this is the default target for the cluster")
|
|
162
|
+
status_message: str | None = Field(default=None, description="Human-readable status message or error details")
|
|
163
|
+
labels: dict[str, str] = Field(description="Key-value labels for the target")
|
|
164
|
+
created_at: datetime = Field(description="Creation timestamp")
|
|
165
|
+
last_ran_at: datetime | None = Field(default=None, description="Last execution timestamp")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ExecutionTargetListParams(EPListParams):
|
|
169
|
+
"""Query parameters for listing execution targets."""
|
|
170
|
+
|
|
171
|
+
id: str | None = Field(default=None, description="Filter by id")
|
|
172
|
+
cluster_id: str | None = Field(default=None, description="Filter by cluster_id")
|
|
173
|
+
name: str | None = Field(default=None, description="Filter by name")
|
|
174
|
+
backend_type: str | None = Field(default=None, description="Filter by backend_type")
|
|
175
|
+
endpoint: str | None = Field(default=None, description="Filter by endpoint")
|
|
176
|
+
status: str | None = Field(default=None, description="Filter by status")
|
|
177
|
+
enabled: str | None = Field(default=None, description="Filter by enabled")
|
|
178
|
+
is_default: str | None = Field(default=None, description="Filter by is_default")
|
|
179
|
+
status_message: str | None = Field(default=None, description="Filter by status_message")
|
|
180
|
+
created_at: str | None = Field(default=None, description="Filter by created_at")
|
|
181
|
+
last_ran_at: str | None = Field(default=None, description="Filter by last_ran_at")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class ExecutionTargetListResponse(ResourcesResponse[ExecutionTargetRead]):
|
|
185
|
+
"""Paginated list response for execution targets."""
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class KubernetesTargetPlacement(CommandKubernetesPlacement):
|
|
189
|
+
"""Validated Kubernetes placement for target-management writes."""
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class ExecutionTargetCreate(BaseModel):
|
|
193
|
+
"""A Kubernetes target on the single cluster provisioned at installation."""
|
|
194
|
+
|
|
195
|
+
model_config = ConfigDict(extra="forbid")
|
|
196
|
+
|
|
197
|
+
name: str = Field(min_length=1, max_length=255)
|
|
198
|
+
placement: KubernetesTargetPlacement
|
|
199
|
+
labels: dict[str, str] = Field(default_factory=dict)
|
|
200
|
+
is_default: bool = False
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class ExecutionTargetUpdate(BaseModel):
|
|
204
|
+
"""Patch mutable target fields; placement requires a namespace."""
|
|
205
|
+
|
|
206
|
+
model_config = ConfigDict(extra="forbid", json_schema_extra={"minProperties": 1})
|
|
207
|
+
|
|
208
|
+
name: Annotated[str, Field(min_length=1, max_length=255)] | SkipJsonSchema[None] = None
|
|
209
|
+
placement: KubernetesTargetPlacement | SkipJsonSchema[None] = None
|
|
210
|
+
labels: dict[str, str] | SkipJsonSchema[None] = None
|
|
211
|
+
is_default: bool | SkipJsonSchema[None] = None
|
|
212
|
+
enabled: bool | SkipJsonSchema[None] = None
|
|
213
|
+
|
|
214
|
+
@model_validator(mode="after")
|
|
215
|
+
def check_fields(self) -> Self:
|
|
216
|
+
"""Reject empty patches and clearing required values before sending a command."""
|
|
217
|
+
if not self.model_fields_set or any(getattr(self, key) is None for key in self.model_fields_set):
|
|
218
|
+
message = "Supply at least one target field; target fields cannot be null"
|
|
219
|
+
raise ValueError(message)
|
|
220
|
+
return self
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class ExecutionTargetDeleteAccepted(BaseModel):
|
|
224
|
+
"""EP accepted deletion; draining and physical removal happen independently."""
|
|
225
|
+
|
|
226
|
+
id: UUID
|
|
227
|
+
accepted: Literal[True] = True
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class ExecutionTargetHealthResult(BaseModel):
|
|
231
|
+
"""Shallow view of an EP on-demand target health probe."""
|
|
232
|
+
|
|
233
|
+
model_config = ConfigDict(extra="forbid")
|
|
234
|
+
|
|
235
|
+
healthy: bool
|
|
236
|
+
message: str | None = None
|
|
237
|
+
skipped: bool = False
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Shared list controls and pagination envelopes."""
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field, StringConstraints
|
|
6
|
+
|
|
7
|
+
_SORT_PATTERN = r"^-?[a-z][a-z0-9_]*$"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class EPListParams(BaseModel):
|
|
11
|
+
"""Query parameters accepted by all EP list endpoints."""
|
|
12
|
+
|
|
13
|
+
limit: int = Field(default=20, gt=0, le=100)
|
|
14
|
+
cursor: str | None = Field(default=None)
|
|
15
|
+
sort: Annotated[str, StringConstraints(pattern=_SORT_PATTERN)] = Field(
|
|
16
|
+
default="created_at", description="Sort field; prefix with '-' for descending order."
|
|
17
|
+
)
|
|
18
|
+
include_total: bool = Field(default=False)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def sort_order(self) -> tuple[str, str]:
|
|
22
|
+
"""Return the selected field and SQL ordering direction."""
|
|
23
|
+
return self.sort.removeprefix("-"), "desc" if self.sort.startswith("-") else "asc"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ResourcesResponse[T](BaseModel):
|
|
27
|
+
"""Pagination envelope returned by all EP list endpoints."""
|
|
28
|
+
|
|
29
|
+
resources: list[T]
|
|
30
|
+
next: str | None = None
|
|
31
|
+
prev: str | None = None
|
|
32
|
+
total: int | None = None
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Shared work-item list and response contracts."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from typing import Annotated, Any
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field, StringConstraints
|
|
9
|
+
|
|
10
|
+
from execution_plane_client.models.shared import _SORT_PATTERN, EPListParams, ResourcesResponse
|
|
11
|
+
|
|
12
|
+
# Work item query metadata - single source of truth for EP and client
|
|
13
|
+
WORK_ITEM_FILTERABLE_FIELDS = [
|
|
14
|
+
"id",
|
|
15
|
+
"execution_target_id",
|
|
16
|
+
"status",
|
|
17
|
+
"created_at",
|
|
18
|
+
"claimed_at",
|
|
19
|
+
"completed_at",
|
|
20
|
+
"resource_cleanup_status",
|
|
21
|
+
"resource_cleanup_error",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
WORK_ITEM_SORTABLE_FIELDS = [
|
|
25
|
+
"created_at",
|
|
26
|
+
"status",
|
|
27
|
+
"resource_cleanup_status",
|
|
28
|
+
"id",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class WorkItemStatus(StrEnum):
|
|
33
|
+
"""Lifecycle states of a dispatched work item."""
|
|
34
|
+
|
|
35
|
+
PENDING = "pending"
|
|
36
|
+
CLAIMED = "claimed"
|
|
37
|
+
DISPATCHED = "dispatched"
|
|
38
|
+
RUNNING = "running"
|
|
39
|
+
CANCEL_REQUESTED = "cancel_requested"
|
|
40
|
+
RECONCILIATION_REQUIRED = "reconciliation_required"
|
|
41
|
+
COMPLETED = "completed"
|
|
42
|
+
FAILED = "failed"
|
|
43
|
+
CANCELLED = "cancelled"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class WorkItemRead(BaseModel):
|
|
47
|
+
"""Safe work-item representation; excludes credentials and persistence internals."""
|
|
48
|
+
|
|
49
|
+
model_config = ConfigDict(from_attributes=True)
|
|
50
|
+
|
|
51
|
+
id: UUID = Field(description="Work item unique identifier")
|
|
52
|
+
status: WorkItemStatus = Field(description="Work item lifecycle status")
|
|
53
|
+
result: dict[str, Any] | None = Field(default=None, description="Work execution result payload")
|
|
54
|
+
result_omitted: bool = Field(default=False, description="Whether result was omitted due to size")
|
|
55
|
+
result_size_bytes: int | None = Field(default=None, description="Size of the result in bytes")
|
|
56
|
+
created_at: datetime = Field(description="Creation timestamp")
|
|
57
|
+
claimed_at: datetime | None = Field(default=None, description="Claim timestamp")
|
|
58
|
+
completed_at: datetime | None = Field(default=None, description="Completion timestamp")
|
|
59
|
+
resource_cleanup_status: str = Field(description="Resource cleanup status")
|
|
60
|
+
resource_cleanup_error: str | None = Field(default=None, description="Resource cleanup error details")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class WorkItemListParams(EPListParams):
|
|
64
|
+
"""Query parameters for listing work items."""
|
|
65
|
+
|
|
66
|
+
id: str | None = Field(default=None, description="Filter by id")
|
|
67
|
+
execution_target_id: str | None = Field(default=None, description="Filter by execution_target_id")
|
|
68
|
+
status: str | None = Field(default=None, description="Filter by status")
|
|
69
|
+
created_at: str | None = Field(default=None, description="Filter by created_at")
|
|
70
|
+
claimed_at: str | None = Field(default=None, description="Filter by claimed_at")
|
|
71
|
+
completed_at: str | None = Field(default=None, description="Filter by completed_at")
|
|
72
|
+
resource_cleanup_status: str | None = Field(default=None, description="Filter by resource_cleanup_status")
|
|
73
|
+
resource_cleanup_error: str | None = Field(default=None, description="Filter by resource_cleanup_error")
|
|
74
|
+
|
|
75
|
+
sort: Annotated[str, StringConstraints(pattern=_SORT_PATTERN)] = Field(
|
|
76
|
+
default="-created_at", description="Sort field; prefix with '-' for descending order."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class WorkItemListResponse(ResourcesResponse[WorkItemRead]):
|
|
81
|
+
"""Paginated list response for work items."""
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "execution-plane-client"
|
|
7
7
|
dynamic = ["version"]
|
|
8
|
-
description = "Shared execution-plane command
|
|
8
|
+
description = "Shared execution-plane command, response, and handler contracts"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
11
11
|
requires-python = ">=3.12,<3.15"
|
|
@@ -27,7 +27,7 @@ raw-options = { search_parent_directories = true, fallback_version = "0.0.0" }
|
|
|
27
27
|
version-file = "_version.py"
|
|
28
28
|
|
|
29
29
|
[tool.hatch.build.targets.wheel]
|
|
30
|
-
include = ["/*.py", "/py.typed", "/commands/**"]
|
|
30
|
+
include = ["/*.py", "/py.typed", "/commands/**", "/models/**"]
|
|
31
31
|
|
|
32
32
|
[tool.hatch.build.targets.wheel.sources]
|
|
33
33
|
"" = "execution_plane_client"
|
|
@@ -36,4 +36,4 @@ include = ["/*.py", "/py.typed", "/commands/**"]
|
|
|
36
36
|
dev-mode-dirs = [".."]
|
|
37
37
|
|
|
38
38
|
[tool.hatch.build.targets.sdist]
|
|
39
|
-
include = ["/*.py", "/py.typed", "/commands/**", "/pyproject.toml", "/README.md", "/LICENSE"]
|
|
39
|
+
include = ["/*.py", "/py.typed", "/commands/**", "/models/**", "/pyproject.toml", "/README.md", "/LICENSE"]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Shared command contracts and participant-owned handler registration."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|