You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/06/15 16:12:18 UTC

(tooling-trusted-releases) branch sbp updated: Add an API endpoint to list distributions

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

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


The following commit(s) were added to refs/heads/sbp by this push:
     new 0d9f4ad2 Add an API endpoint to list distributions
0d9f4ad2 is described below

commit 0d9f4ad2f2bd313aadd5eb4d334ca2f80781a237
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon Jun 15 17:11:54 2026 +0100

    Add an API endpoint to list distributions
---
 atr/api/__init__.py | 37 +++++++++++++++++++++++++++++++++++++
 atr/models/api.py   | 24 ++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/atr/api/__init__.py b/atr/api/__init__.py
index dee13116..fc4e7a8b 100644
--- a/atr/api/__init__.py
+++ b/atr/api/__init__.py
@@ -449,6 +449,43 @@ async def distribute_ssh_register(
     ).model_dump(mode="json"), 200
 
 
+@api.typed(
+    auth_scheme=api_auth.Auth.PUBLIC,
+    response=(models.api.DistributionListResults, 200),
+)
+async def distribution_list(
+    _distribution_list: Literal["distribution/list"],
+    project_key: safe.ProjectKey,
+    version_key: safe.VersionKey,
+) -> DictResponse:
+    """
+    URL: GET /distribution/list/<project_key>/<version_key>
+
+    List recorded distributions for a release.
+    """
+    async with db.session() as data:
+        release_key = sql.release_key(str(project_key), str(version_key))
+        distributions = await data.distribution(release_key=str(release_key)).all()
+    entries = [
+        models.api.DistributionListEntry(
+            platform=dist.platform.name,
+            owner_namespace=dist.owner_namespace,
+            package=dist.package,
+            version=dist.version,
+            staging=dist.staging,
+            pending=dist.pending,
+            upload_date=dist.upload_date,
+            api_url=dist.api_url,
+            web_url=dist.web_url,
+        )
+        for dist in distributions
+    ]
+    return models.api.DistributionListResults(
+        endpoint="/distribution/list",
+        distributions=entries,
+    ).model_dump(mode="json"), 200
+
+
 @api.typed(
     auth_scheme=api_auth.Auth.BEARER,
     response=(models.api.DistributionRecordResults, 200),
diff --git a/atr/models/api.py b/atr/models/api.py
index 9227b3b3..535acc12 100644
--- a/atr/models/api.py
+++ b/atr/models/api.py
@@ -155,6 +155,28 @@ class DistributeStatusUpdateResults(schema.Strict):
     success: Literal[True] = schema.example(True)
 
 
+class DistributionListEntry(schema.Strict):
+    platform: str = schema.example("ARTIFACT_HUB")
+    owner_namespace: str = schema.default_example("", "example")
+    package: str = schema.example("example")
+    version: str = schema.example("0.0.1")
+    staging: bool = schema.example(False)
+    pending: bool = schema.example(False)
+    upload_date: datetime.datetime | None = schema.default(None)
+    api_url: str | None = schema.default(None)
+    web_url: str | None = schema.default(None)
+
+    @pydantic.field_validator("upload_date", mode="before")
+    @classmethod
+    def upload_date_from_iso(cls, v):
+        return datetime.datetime.fromisoformat(v) if isinstance(v, str) else v
+
+
+class DistributionListResults(schema.Strict):
+    endpoint: Literal["/distribution/list"] = schema.alias("endpoint")
+    distributions: Sequence[DistributionListEntry]
+
+
 class DistributionRecordArgs(schema.Strict):
     project: safe.ProjectKey = schema.example("example")
     version: safe.VersionKey = schema.example("0.0.1")
@@ -914,6 +936,7 @@ type Results = Annotated[
     | CommitteeKeysResults
     | CommitteeProjectsResults
     | CommitteesListResults
+    | DistributionListResults
     | DistributionRecordResults
     | IgnoreAddResults
     | IgnoreDeleteResults
@@ -973,6 +996,7 @@ validate_committee_get = validator(CommitteeGetResults)
 validate_committee_keys = validator(CommitteeKeysResults)
 validate_committee_projects = validator(CommitteeProjectsResults)
 validate_committees_list = validator(CommitteesListResults)
+validate_distribution_list = validator(DistributionListResults)
 validate_distribution_record = validator(DistributionRecordResults)
 validate_distribution_ssh_register = validator(DistributeSshRegisterResults)
 validate_ignore_add = validator(IgnoreAddResults)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org