execution-plane-client 0.1.10__tar.gz → 0.1.12__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.10 → execution_plane_client-0.1.12}/PKG-INFO +4 -4
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/README.md +2 -2
- execution_plane_client-0.1.12/__init__.py +1 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/_version.py +2 -2
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/catalog.py +2 -1
- execution_plane_client-0.1.12/commands/credentials.py +15 -0
- execution_plane_client-0.1.12/commands/results.py +43 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/targets.py +8 -2
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/handlers.py +2 -0
- execution_plane_client-0.1.12/models/__init__.py +1 -0
- execution_plane_client-0.1.12/models/cluster.py +60 -0
- execution_plane_client-0.1.12/models/execution_target.py +228 -0
- execution_plane_client-0.1.12/models/shared.py +30 -0
- execution_plane_client-0.1.12/models/work_item.py +67 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/protocol.py +0 -8
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/pyproject.toml +3 -3
- execution_plane_client-0.1.10/__init__.py +0 -1
- execution_plane_client-0.1.10/commands/credentials.py +0 -25
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/.gitignore +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/LICENSE +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/__init__.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/base.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/clusters.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/control.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/commands/work.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/errors.py +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/py.typed +0 -0
- {execution_plane_client-0.1.10 → execution_plane_client-0.1.12}/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.12
|
|
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
|
|
@@ -45,8 +45,8 @@ message = ClusterRegister(
|
|
|
45
45
|
body = message.model_dump(mode="json") # Send using your application's HTTP client.
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
Every concrete command supports this method, including `ClusterDelete
|
|
49
|
-
`TargetDelete`. Partial updates serialize only supplied fields, retaining explicit
|
|
48
|
+
Every concrete command supports this method, including `ClusterDelete`,
|
|
49
|
+
`TargetDelete` and `TargetHealth`. Partial updates serialize only supplied fields, retaining explicit
|
|
50
50
|
nulls and placement discriminators without resetting omitted configuration.
|
|
51
51
|
|
|
52
52
|
By default, each call generates a command UUID and UTC timestamp; `message_id`
|
|
@@ -35,8 +35,8 @@ message = ClusterRegister(
|
|
|
35
35
|
body = message.model_dump(mode="json") # Send using your application's HTTP client.
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Every concrete command supports this method, including `ClusterDelete
|
|
39
|
-
`TargetDelete`. Partial updates serialize only supplied fields, retaining explicit
|
|
38
|
+
Every concrete command supports this method, including `ClusterDelete`,
|
|
39
|
+
`TargetDelete` and `TargetHealth`. Partial updates serialize only supplied fields, retaining explicit
|
|
40
40
|
nulls and placement discriminators without resetting omitted configuration.
|
|
41
41
|
|
|
42
42
|
By default, each call generates a command UUID and UTC timestamp; `message_id`
|
|
@@ -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.12'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 12)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -6,7 +6,7 @@ from execution_plane_client.commands.base import CommandPayload
|
|
|
6
6
|
from execution_plane_client.commands.clusters import ClusterDelete, ClusterProvision, ClusterRegister, ClusterUpdate
|
|
7
7
|
from execution_plane_client.commands.control import CancelCommand, Completion
|
|
8
8
|
from execution_plane_client.commands.credentials import CredentialResolve
|
|
9
|
-
from execution_plane_client.commands.targets import TargetDelete, TargetRegister, TargetUpdate
|
|
9
|
+
from execution_plane_client.commands.targets import TargetDelete, TargetHealth, TargetRegister, TargetUpdate
|
|
10
10
|
from execution_plane_client.commands.work import WorkExecute
|
|
11
11
|
from execution_plane_client.errors import UnsupportedCommand
|
|
12
12
|
from execution_plane_client.protocol import MessageEnvelope
|
|
@@ -37,6 +37,7 @@ class CommandCatalog:
|
|
|
37
37
|
TargetRegister,
|
|
38
38
|
TargetUpdate,
|
|
39
39
|
TargetDelete,
|
|
40
|
+
TargetHealth,
|
|
40
41
|
CancelCommand,
|
|
41
42
|
)
|
|
42
43
|
self._definitions = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Credential-reference resolution commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import ClassVar
|
|
6
|
+
from uuid import UUID # noqa: TC003 - Pydantic evaluates fields.
|
|
7
|
+
|
|
8
|
+
from execution_plane_client.commands.base import CommandPayload
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CredentialResolve(CommandPayload):
|
|
12
|
+
"""Resolve an opaque credential reference into a short-lived value."""
|
|
13
|
+
|
|
14
|
+
command_type: ClassVar[str] = "credential.resolve"
|
|
15
|
+
credential_ref: UUID
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Typed command results and transport receipts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal
|
|
6
|
+
from uuid import UUID # noqa: TC003 - Pydantic resolves this model field at runtime.
|
|
7
|
+
|
|
8
|
+
from pydantic import Field, StrictBool, StrictStr
|
|
9
|
+
|
|
10
|
+
from execution_plane_client.protocol import ResourceReference, WireModel
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CredentialResolveCommandResult(WireModel):
|
|
14
|
+
"""Typed result returned for a credential-resolution command."""
|
|
15
|
+
|
|
16
|
+
command_type: Literal["credential.resolve"] = "credential.resolve"
|
|
17
|
+
command_revision: Literal[1] = 1
|
|
18
|
+
credential: Annotated[StrictStr, Field(min_length=1, max_length=65536, repr=False)]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TargetHealthCommandResult(WireModel):
|
|
22
|
+
"""Typed result returned for an execution-target health command."""
|
|
23
|
+
|
|
24
|
+
command_type: Literal["execution_target.health"] = "execution_target.health"
|
|
25
|
+
command_revision: Literal[1] = 1
|
|
26
|
+
healthy: StrictBool
|
|
27
|
+
message: StrictStr | None = None
|
|
28
|
+
skipped: StrictBool = False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
CommandResult = Annotated[
|
|
32
|
+
CredentialResolveCommandResult | TargetHealthCommandResult,
|
|
33
|
+
Field(discriminator="command_type"),
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class TransportReceipt(WireModel):
|
|
38
|
+
"""Receipt of a handled request, without a persisted command record."""
|
|
39
|
+
|
|
40
|
+
received: Literal[True] = True
|
|
41
|
+
message_id: UUID
|
|
42
|
+
resource: ResourceReference | None = None
|
|
43
|
+
result: CommandResult | None = 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
|
|
@@ -150,3 +150,9 @@ class TargetUpdate(ResourceIdentity, CommandPayload):
|
|
|
150
150
|
def check_endpoint(cls, value: str | None) -> str | None:
|
|
151
151
|
"""Validate explicit endpoint updates before applying them."""
|
|
152
152
|
return None if value is None else validate_endpoint(value)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class TargetHealth(ResourceIdentity, CommandPayload):
|
|
156
|
+
"""Query the current health of one ExecutionTarget."""
|
|
157
|
+
|
|
158
|
+
command_type: ClassVar[str] = "execution_target.health"
|
|
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
|
|
4
4
|
from typing import Protocol
|
|
5
5
|
|
|
6
6
|
from execution_plane_client.commands.base import CommandPayload
|
|
7
|
+
from execution_plane_client.commands.results import CommandResult
|
|
7
8
|
from execution_plane_client.protocol import MessageEnvelope, ResourceReference
|
|
8
9
|
|
|
9
10
|
|
|
@@ -12,6 +13,7 @@ class HandlingResult:
|
|
|
12
13
|
"""Optional resource created or affected by a command."""
|
|
13
14
|
|
|
14
15
|
resource: ResourceReference | None = None
|
|
16
|
+
result: CommandResult | None = None
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
class CommandHandler[ContextT](Protocol):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shared Execution Plane REST resource contracts; import from feature modules."""
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Shared cluster list and response contracts."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Literal
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
|
+
|
|
9
|
+
from execution_plane_client.models.shared import EPListParams
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ClusterListParams(EPListParams):
|
|
13
|
+
"""Cluster query controls and documented filter fields."""
|
|
14
|
+
|
|
15
|
+
id: str | None = Field(default=None, description="Cluster UUID; id[in]=uuid1,uuid2 for membership")
|
|
16
|
+
created_at: str | None = Field(
|
|
17
|
+
default=None, description="Creation time; supports eq, in, gt, gte, lt, lte, and isnull"
|
|
18
|
+
)
|
|
19
|
+
updated_at: str | None = Field(default=None, description="Update time; supports ranges and isnull")
|
|
20
|
+
name: str | None = Field(default=None, description="Name; supports eq, in, contains, and starts_with")
|
|
21
|
+
endpoint: str | None = Field(default=None, description="Endpoint; supports eq, in, contains, and starts_with")
|
|
22
|
+
status: str | None = Field(default=None, description="Cluster status; supports eq and in")
|
|
23
|
+
status_message: str | None = Field(default=None, description="Status message; supports text operators and isnull")
|
|
24
|
+
enabled: str | None = Field(default=None, description="Boolean; supports eq, in, and isnull")
|
|
25
|
+
is_default: str | None = Field(default=None, description="Boolean; supports eq, in, and isnull")
|
|
26
|
+
sort: Literal[
|
|
27
|
+
"id",
|
|
28
|
+
"-id",
|
|
29
|
+
"created_at",
|
|
30
|
+
"-created_at",
|
|
31
|
+
"name",
|
|
32
|
+
"-name",
|
|
33
|
+
"endpoint",
|
|
34
|
+
"-endpoint",
|
|
35
|
+
"status",
|
|
36
|
+
"-status",
|
|
37
|
+
"enabled",
|
|
38
|
+
"-enabled",
|
|
39
|
+
"is_default",
|
|
40
|
+
"-is_default",
|
|
41
|
+
"updated_at",
|
|
42
|
+
"-updated_at",
|
|
43
|
+
] = Field(default="created_at", description="Cluster sort field; oldest first by default.")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ClusterRead(BaseModel):
|
|
47
|
+
"""Provisioned cluster state, keyed by the actual cluster UUID."""
|
|
48
|
+
|
|
49
|
+
model_config = ConfigDict(from_attributes=True)
|
|
50
|
+
|
|
51
|
+
id: UUID
|
|
52
|
+
name: str
|
|
53
|
+
endpoint: str
|
|
54
|
+
status: str
|
|
55
|
+
status_message: str | None
|
|
56
|
+
enabled: bool
|
|
57
|
+
is_default: bool
|
|
58
|
+
labels: dict[str, str]
|
|
59
|
+
created_at: datetime
|
|
60
|
+
updated_at: datetime
|
|
@@ -0,0 +1,228 @@
|
|
|
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
|
|
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
|
+
|
|
22
|
+
class BackendType(StrEnum):
|
|
23
|
+
"""Supported execution target backends."""
|
|
24
|
+
|
|
25
|
+
KUBERNETES = "kubernetes"
|
|
26
|
+
OPENSHELL = "openshell"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TargetStatus(StrEnum):
|
|
30
|
+
"""Lifecycle states of an execution target."""
|
|
31
|
+
|
|
32
|
+
REGISTERING = "registering"
|
|
33
|
+
VALIDATING = "validating"
|
|
34
|
+
BOOTSTRAPPING = "bootstrapping"
|
|
35
|
+
ACTIVE = "active"
|
|
36
|
+
DEGRADED = "degraded"
|
|
37
|
+
DRAINING = "draining"
|
|
38
|
+
FAILED = "failed"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _is_valid_label_key(value: str) -> bool:
|
|
42
|
+
"""Return whether a value uses Kubernetes label-key syntax."""
|
|
43
|
+
prefix, separator, name = value.partition("/")
|
|
44
|
+
if separator:
|
|
45
|
+
prefix_labels = prefix.split(".")
|
|
46
|
+
if (
|
|
47
|
+
not prefix
|
|
48
|
+
or len(prefix) > _MAX_DNS_SUBDOMAIN_LENGTH
|
|
49
|
+
or any(len(label) > _MAX_LABEL_NAME_LENGTH or not _DNS_LABEL.fullmatch(label) for label in prefix_labels)
|
|
50
|
+
):
|
|
51
|
+
return False
|
|
52
|
+
else:
|
|
53
|
+
name = prefix
|
|
54
|
+
return len(name) <= _MAX_LABEL_NAME_LENGTH and bool(_LABEL_NAME.fullmatch(name))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _is_valid_label_value(value: str) -> bool:
|
|
58
|
+
"""Return whether a value uses Kubernetes label-value syntax."""
|
|
59
|
+
return len(value) <= _MAX_LABEL_NAME_LENGTH and (value == "" or bool(_LABEL_NAME.fullmatch(value)))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class KubernetesPlacement(BaseModel):
|
|
63
|
+
"""Metadata required to place workers on Kubernetes."""
|
|
64
|
+
|
|
65
|
+
type: Literal["kubernetes"] = "kubernetes"
|
|
66
|
+
namespace: str = Field(
|
|
67
|
+
min_length=1,
|
|
68
|
+
max_length=63,
|
|
69
|
+
pattern=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
|
|
70
|
+
description="Kubernetes namespace reserved for execution workloads",
|
|
71
|
+
)
|
|
72
|
+
node_selectors: list[str] = Field(default_factory=list)
|
|
73
|
+
tolerations: list[str] = Field(default_factory=list)
|
|
74
|
+
|
|
75
|
+
@field_validator("node_selectors")
|
|
76
|
+
@classmethod
|
|
77
|
+
def validate_node_selectors(cls, values: list[str]) -> list[str]:
|
|
78
|
+
"""Validate compact Kubernetes node-selector expressions."""
|
|
79
|
+
for value in values:
|
|
80
|
+
key, separator, selector_value = value.partition("=")
|
|
81
|
+
if not separator or not _is_valid_label_key(key) or not _is_valid_label_value(selector_value):
|
|
82
|
+
message = "must use a valid Kubernetes label selector in key=value form"
|
|
83
|
+
raise ValueError(message)
|
|
84
|
+
return values
|
|
85
|
+
|
|
86
|
+
@field_validator("tolerations")
|
|
87
|
+
@classmethod
|
|
88
|
+
def validate_tolerations(cls, values: list[str]) -> list[str]:
|
|
89
|
+
"""Validate compact Kubernetes toleration expressions."""
|
|
90
|
+
for value in values:
|
|
91
|
+
key_value, separator, effect = value.rpartition(":")
|
|
92
|
+
if not separator:
|
|
93
|
+
key_value = value
|
|
94
|
+
effect = ""
|
|
95
|
+
key, equals, toleration_value = key_value.partition("=")
|
|
96
|
+
if equals:
|
|
97
|
+
valid_key = bool(key) and _is_valid_label_key(key)
|
|
98
|
+
valid_value = _is_valid_label_value(toleration_value)
|
|
99
|
+
else:
|
|
100
|
+
valid_key = not key or _is_valid_label_key(key)
|
|
101
|
+
valid_value = not toleration_value
|
|
102
|
+
if not valid_key or not valid_value or effect not in _TOLERATION_EFFECTS:
|
|
103
|
+
message = "must use a valid Kubernetes toleration short form"
|
|
104
|
+
raise ValueError(message)
|
|
105
|
+
return values
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class RHELPlacement(BaseModel):
|
|
109
|
+
"""Placeholder for RHEL-specific execution-target metadata."""
|
|
110
|
+
|
|
111
|
+
type: Literal["rhel"] = "rhel"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
ExecutionTargetPlacementTypes = KubernetesPlacement | RHELPlacement
|
|
115
|
+
ExecutionTargetPlacement = Annotated[
|
|
116
|
+
ExecutionTargetPlacementTypes,
|
|
117
|
+
Field(discriminator="type"),
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class ExecutionTargetListParams(EPListParams):
|
|
122
|
+
"""Execution-target query controls and documented filter fields."""
|
|
123
|
+
|
|
124
|
+
id: str | None = Field(default=None, description="Target UUID; id[in]=uuid1,uuid2 for membership")
|
|
125
|
+
cluster_id: str | None = Field(default=None, description="Physical cluster UUID; supports eq and in")
|
|
126
|
+
name: str | None = Field(default=None, description="Name; supports eq, in, contains, and starts_with")
|
|
127
|
+
endpoint: str | None = Field(default=None, description="Endpoint; supports eq, in, contains, and starts_with")
|
|
128
|
+
status: str | None = Field(default=None, description="Target status; supports eq and in")
|
|
129
|
+
backend_type: str | None = Field(default=None, description="Backend type; supports eq and in")
|
|
130
|
+
enabled: str | None = Field(default=None, description="Boolean; supports eq, in, and isnull")
|
|
131
|
+
is_default: str | None = Field(default=None, description="Boolean; supports eq, in, and isnull")
|
|
132
|
+
created_at: str | None = Field(
|
|
133
|
+
default=None, description="Creation time; supports eq, in, gt, gte, lt, lte, and isnull"
|
|
134
|
+
)
|
|
135
|
+
last_ran_at: str | None = Field(default=None, description="Last run time; supports ranges and isnull")
|
|
136
|
+
status_message: str | None = Field(default=None, description="Status message; supports text operators and isnull")
|
|
137
|
+
sort: Literal[
|
|
138
|
+
"id",
|
|
139
|
+
"-id",
|
|
140
|
+
"created_at",
|
|
141
|
+
"-created_at",
|
|
142
|
+
"name",
|
|
143
|
+
"-name",
|
|
144
|
+
"endpoint",
|
|
145
|
+
"-endpoint",
|
|
146
|
+
"status",
|
|
147
|
+
"-status",
|
|
148
|
+
"backend_type",
|
|
149
|
+
"-backend_type",
|
|
150
|
+
"cluster_id",
|
|
151
|
+
"-cluster_id",
|
|
152
|
+
"enabled",
|
|
153
|
+
"-enabled",
|
|
154
|
+
"is_default",
|
|
155
|
+
"-is_default",
|
|
156
|
+
] = Field(default="created_at", description="Execution-target sort field; oldest first by default.")
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class ExecutionTargetRead(BaseModel):
|
|
160
|
+
"""Safe execution-target representation without management credentials."""
|
|
161
|
+
|
|
162
|
+
model_config = ConfigDict(from_attributes=True)
|
|
163
|
+
|
|
164
|
+
id: UUID
|
|
165
|
+
cluster_id: UUID
|
|
166
|
+
name: str
|
|
167
|
+
backend_type: BackendType
|
|
168
|
+
endpoint: str
|
|
169
|
+
placement: ExecutionTargetPlacement
|
|
170
|
+
status: TargetStatus
|
|
171
|
+
enabled: bool
|
|
172
|
+
is_default: bool
|
|
173
|
+
status_message: str | None
|
|
174
|
+
labels: dict[str, str]
|
|
175
|
+
created_at: datetime
|
|
176
|
+
last_ran_at: datetime | None
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class KubernetesTargetPlacement(CommandKubernetesPlacement):
|
|
180
|
+
"""Validated Kubernetes placement for target-management writes."""
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class ExecutionTargetCreate(BaseModel):
|
|
184
|
+
"""A Kubernetes target on the single cluster provisioned at installation."""
|
|
185
|
+
|
|
186
|
+
model_config = ConfigDict(extra="forbid")
|
|
187
|
+
|
|
188
|
+
name: str = Field(min_length=1, max_length=255)
|
|
189
|
+
placement: KubernetesTargetPlacement
|
|
190
|
+
labels: dict[str, str] = Field(default_factory=dict)
|
|
191
|
+
is_default: bool = False
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ExecutionTargetUpdate(BaseModel):
|
|
195
|
+
"""Patch mutable target fields; placement requires a namespace."""
|
|
196
|
+
|
|
197
|
+
model_config = ConfigDict(extra="forbid", json_schema_extra={"minProperties": 1})
|
|
198
|
+
|
|
199
|
+
name: Annotated[str, Field(min_length=1, max_length=255)] | SkipJsonSchema[None] = None
|
|
200
|
+
placement: KubernetesTargetPlacement | SkipJsonSchema[None] = None
|
|
201
|
+
labels: dict[str, str] | SkipJsonSchema[None] = None
|
|
202
|
+
is_default: bool | SkipJsonSchema[None] = None
|
|
203
|
+
enabled: bool | SkipJsonSchema[None] = None
|
|
204
|
+
|
|
205
|
+
@model_validator(mode="after")
|
|
206
|
+
def check_fields(self) -> Self:
|
|
207
|
+
"""Reject empty patches and clearing required values before sending a command."""
|
|
208
|
+
if not self.model_fields_set or any(getattr(self, key) is None for key in self.model_fields_set):
|
|
209
|
+
message = "Supply at least one target field; target fields cannot be null"
|
|
210
|
+
raise ValueError(message)
|
|
211
|
+
return self
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class ExecutionTargetDeleteAccepted(BaseModel):
|
|
215
|
+
"""EP accepted deletion; draining and physical removal happen independently."""
|
|
216
|
+
|
|
217
|
+
id: UUID
|
|
218
|
+
accepted: Literal[True] = True
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class ExecutionTargetHealthResult(BaseModel):
|
|
222
|
+
"""Shallow view of an EP on-demand target health probe."""
|
|
223
|
+
|
|
224
|
+
model_config = ConfigDict(extra="forbid")
|
|
225
|
+
|
|
226
|
+
healthy: bool
|
|
227
|
+
message: str | None = None
|
|
228
|
+
skipped: bool = False
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Shared list controls and pagination envelopes."""
|
|
2
|
+
|
|
3
|
+
from typing import Generic, TypeVar
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
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: str = Field(default="-created_at", description="Sort field; prefix with '-' for descending order.")
|
|
16
|
+
include_total: bool = Field(default=False)
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def sort_order(self) -> tuple[str, str]:
|
|
20
|
+
"""Return the selected field and SQL ordering direction."""
|
|
21
|
+
return self.sort.removeprefix("-"), "desc" if self.sort.startswith("-") else "asc"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ResourcesResponse(BaseModel, Generic[T]): # noqa: UP046
|
|
25
|
+
"""Pagination envelope returned by all EP list endpoints."""
|
|
26
|
+
|
|
27
|
+
resources: list[T]
|
|
28
|
+
next: str | None = None
|
|
29
|
+
prev: str | None = None
|
|
30
|
+
total: int | None = None
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Shared work-item list and response contracts."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
9
|
+
|
|
10
|
+
from execution_plane_client.models.shared import EPListParams
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class WorkItemStatus(StrEnum):
|
|
14
|
+
"""Lifecycle states of a dispatched work item."""
|
|
15
|
+
|
|
16
|
+
PENDING = "pending"
|
|
17
|
+
CLAIMED = "claimed"
|
|
18
|
+
DISPATCHED = "dispatched"
|
|
19
|
+
RUNNING = "running"
|
|
20
|
+
CANCEL_REQUESTED = "cancel_requested"
|
|
21
|
+
RECONCILIATION_REQUIRED = "reconciliation_required"
|
|
22
|
+
COMPLETED = "completed"
|
|
23
|
+
FAILED = "failed"
|
|
24
|
+
CANCELLED = "cancelled"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class WorkItemListParams(EPListParams):
|
|
28
|
+
"""Work-item query controls and documented filter fields."""
|
|
29
|
+
|
|
30
|
+
id: str | None = Field(default=None, description="Work UUID; id[in]=uuid1,uuid2 for membership")
|
|
31
|
+
status: str | None = Field(default=None, description="Work status; supports eq and in")
|
|
32
|
+
created_at: str | None = Field(
|
|
33
|
+
default=None, description="Creation time; supports eq, in, gt, gte, lt, lte, and isnull"
|
|
34
|
+
)
|
|
35
|
+
claimed_at: str | None = Field(default=None, description="Claim time; supports ranges and isnull")
|
|
36
|
+
completed_at: str | None = Field(default=None, description="Completion time; supports ranges and isnull")
|
|
37
|
+
resource_cleanup_status: str | None = Field(default=None, description="Cleanup status; supports eq and in")
|
|
38
|
+
resource_cleanup_error: str | None = Field(
|
|
39
|
+
default=None, description="Cleanup error; supports text operators and isnull"
|
|
40
|
+
)
|
|
41
|
+
sort: Literal[
|
|
42
|
+
"created_at",
|
|
43
|
+
"-created_at",
|
|
44
|
+
"status",
|
|
45
|
+
"-status",
|
|
46
|
+
"resource_cleanup_status",
|
|
47
|
+
"-resource_cleanup_status",
|
|
48
|
+
"id",
|
|
49
|
+
"-id",
|
|
50
|
+
] = Field(default="-created_at", description="Work-item sort field; newest first by default.")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class WorkItemRead(BaseModel):
|
|
54
|
+
"""Safe work-item representation; excludes credentials and persistence internals."""
|
|
55
|
+
|
|
56
|
+
model_config = ConfigDict(from_attributes=True)
|
|
57
|
+
|
|
58
|
+
id: UUID
|
|
59
|
+
status: WorkItemStatus
|
|
60
|
+
result: dict[str, Any] | None
|
|
61
|
+
result_omitted: bool = False
|
|
62
|
+
result_size_bytes: int | None = None
|
|
63
|
+
created_at: datetime
|
|
64
|
+
claimed_at: datetime | None
|
|
65
|
+
completed_at: datetime | None
|
|
66
|
+
resource_cleanup_status: str
|
|
67
|
+
resource_cleanup_error: str | None
|
|
@@ -123,11 +123,3 @@ class CapabilitiesRead(WireModel):
|
|
|
123
123
|
|
|
124
124
|
protocol_revision: Literal[1] = 1
|
|
125
125
|
commands: dict[str, list[int]]
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
class TransportReceipt(WireModel):
|
|
129
|
-
"""Receipt of a handled request, without a persisted command record."""
|
|
130
|
-
|
|
131
|
-
received: Literal[True] = True
|
|
132
|
-
message_id: UUID
|
|
133
|
-
resource: ResourceReference | None = None
|
|
@@ -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."""
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"""Credential-reference resolution commands and responses."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import Annotated, ClassVar
|
|
6
|
-
from uuid import UUID # noqa: TC003 - Pydantic evaluates fields.
|
|
7
|
-
|
|
8
|
-
from pydantic import Field, StrictStr
|
|
9
|
-
|
|
10
|
-
from execution_plane_client.commands.base import CommandPayload
|
|
11
|
-
from execution_plane_client.protocol import WireModel
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class CredentialResolve(CommandPayload):
|
|
15
|
-
"""Resolve an opaque credential reference into a short-lived value."""
|
|
16
|
-
|
|
17
|
-
command_type: ClassVar[str] = "credential.resolve"
|
|
18
|
-
credential_ref: UUID
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class CredentialResolution(WireModel):
|
|
22
|
-
"""The resolved credential value for one submitted command."""
|
|
23
|
-
|
|
24
|
-
message_id: UUID
|
|
25
|
-
credential: Annotated[StrictStr, Field(min_length=1, max_length=65536, repr=False)]
|
|
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
|