This is an automated email from the ASF dual-hosted git repository.

arm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new 1b15169  Support the new distribution record function
1b15169 is described below

commit 1b15169aab0f3abe4455afb324c8a5d28687c684
Author: Alastair McFarlane <[email protected]>
AuthorDate: Wed Jan 14 13:27:02 2026 +0000

    Support the new distribution record function
---
 atr/api/__init__.py | 38 ++++++++++++++++++++++++++++++++++++++
 atr/models/api.py   | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/atr/api/__init__.py b/atr/api/__init__.py
index b9da6cd..7c9d19a 100644
--- a/atr/api/__init__.py
+++ b/atr/api/__init__.py
@@ -343,6 +343,44 @@ async def distribution_record(data: 
models.api.DistributionRecordArgs) -> DictRe
     ).model_dump(), 200
 
 
[email protected]("/distribute/record_from_workflow", methods=["POST"])
+@quart_schema.validate_request(models.api.DistributeStatusUpdateArgs)
+async def distribution_record_from_workflow(data: 
models.api.DistributionRecordFromWorkflowArgs) -> DictResponse:
+    """
+    Record a distribution.
+    """
+    _payload, asf_uid, _project, release = await 
interaction.trusted_jwt_for_dist(
+        data.publisher,
+        data.jwt,
+        data.asf_uid,
+        interaction.TrustedProjectPhase(data.phase),
+        data.project,
+        data.version,
+    )
+    # TODO: Split the below code into a new function and reuse in /publisher 
and /distribution / record.
+    if release.committee is None:
+        raise exceptions.NotFound(f"Release {release.name} has no committee")
+    dd = models.distribution.Data(
+        platform=data.platform,
+        owner_namespace=data.distribution_owner_namespace,
+        package=data.distribution_package,
+        version=data.distribution_version,
+        details=data.details,
+    )
+    async with storage.write(asf_uid) as write:
+        wacm = write.as_committee_member(release.committee.name)
+        await wacm.distributions.record_from_data(
+            release.name,
+            data.staging,
+            dd,
+        )
+
+    return models.api.DistributionRecordFromWorkflowResults(
+        endpoint="/distribute/record_from_workflow",
+        success=True,
+    ).model_dump(), 200
+
+
 @api.route("/ignore/add", methods=["POST"])
 @jwtoken.require
 @quart_schema.security_scheme([{"BearerAuth": []}])
diff --git a/atr/models/api.py b/atr/models/api.py
index 85c79ca..e4fff34 100644
--- a/atr/models/api.py
+++ b/atr/models/api.py
@@ -124,6 +124,40 @@ class DistributionRecordArgs(schema.Strict):
         return v.name if isinstance(v, sql.DistributionPlatform) else v
 
 
+class DistributionRecordFromWorkflowArgs(schema.Strict):
+    asf_uid: str = schema.example("user")
+    publisher: str = schema.example("user")
+    jwt: str = schema.example("eyJhbGciOiJIUzI1[...]mMjLiuyu5CSpyHI=")
+    project: str = schema.example("example")
+    version: str = schema.example("0.0.1")
+    platform: sql.DistributionPlatform = 
schema.example(sql.DistributionPlatform.ARTIFACT_HUB)
+    distribution_owner_namespace: str | None = schema.default_example(None, 
"example")
+    distribution_package: str = schema.example("example")
+    distribution_version: str = schema.example("0.0.1")
+    phase: str = schema.Field(strict=False, default="compose", 
json_schema_extra={"examples": ["compose", "finish"]})
+    staging: bool = schema.example(False)
+    details: bool = schema.example(False)
+
+    @pydantic.field_validator("platform", mode="before")
+    @classmethod
+    def platform_to_enum(cls, v):
+        if isinstance(v, str):
+            try:
+                return sql.DistributionPlatform.__members__[v]
+            except KeyError:
+                raise ValueError(f"'{v}' is not a valid DistributionPlatform")
+        return v
+
+    @pydantic.field_serializer("platform")
+    def serialise_platform(self, v):
+        return v.name if isinstance(v, sql.DistributionPlatform) else v
+
+
+class DistributionRecordFromWorkflowResults(schema.Strict):
+    endpoint: Literal["/distribute/record_from_workflow"] = 
schema.alias("endpoint")
+    success: Literal[True] = schema.example(True)
+
+
 class DistributionRecordResults(schema.Strict):
     endpoint: Literal["/distribution/record"] = schema.alias("endpoint")
     success: Literal[True] = schema.example(True)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to