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

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


The following commit(s) were added to refs/heads/main by this push:
     new c230f3a  Add a command to POST to an arbitrary API endpoint
c230f3a is described below

commit c230f3a3171230a4c083ad884f0bcedd1e33d655
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Jul 24 19:14:10 2025 +0100

    Add a command to POST to an arbitrary API endpoint
---
 pyproject.toml          |  4 ++--
 src/atrclient/client.py | 27 ++++++++++++++++++++++++++-
 uv.lock                 |  4 ++--
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 910394e..73306cf 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ build-backend = "hatchling.build"
 
 [project]
 name            = "apache-trusted-releases"
-version         = "0.20250724.1424"
+version         = "0.20250724.1813"
 description     = "ATR CLI and Python API"
 readme          = "README.md"
 requires-python = ">=3.13"
@@ -72,4 +72,4 @@ select = [
 ]
 
 [tool.uv]
-exclude-newer = "2025-07-24T14:24:00Z"
+exclude-newer = "2025-07-24T18:13:00Z"
diff --git a/src/atrclient/client.py b/src/atrclient/client.py
index 06e6c50..3db100c 100755
--- a/src/atrclient/client.py
+++ b/src/atrclient/client.py
@@ -286,6 +286,27 @@ def app_announce(
     print(announce.success)
 
 
[email protected](name="api", help="Call the API directly.")
+async def app_api(path: str, /, **kwargs: str) -> None:
+    print("app_api")
+    jwt_value = config_jwt_usable()
+    host, verify_ssl = config_host_get()
+    url = f"https://{host}/api{path}";
+    # if debugging:
+    #     print(url)
+    #     print(kwargs)
+    if "_version" in kwargs:
+        # There's a bug in Cyclopts where it does not pass --version to 
**kwargs
+        kwargs["version"] = kwargs["_version"]
+        del kwargs["_version"]
+    if not is_json(kwargs):
+        show_error_and_exit(f"Unexpected API response: {kwargs}")
+    if not is_json_dict(kwargs):
+        show_error_and_exit(f"Unexpected API response: {kwargs}")
+    json_data = await web_post_json(url, kwargs, jwt_value, verify_ssl)
+    print(json.dumps(json_data, indent=None))
+
+
 @APP_CHECKS.command(name="exceptions", help="Get check exceptions for a 
release revision.")
 def app_checks_exceptions(
     project: str,
@@ -1280,12 +1301,16 @@ async def web_get(url: str, jwt_token: str | None, 
verify_ssl: bool = True) -> J
 
 
 async def web_post(url: str, args: models.schema.Strict, jwt_token: str | 
None, verify_ssl: bool = True) -> JSON:
+    return await web_post_json(url, args.model_dump(), jwt_token, verify_ssl)
+
+
+async def web_post_json(url: str, args: JSON, jwt_token: str | None, 
verify_ssl: bool = True) -> JSON:
     connector = None if verify_ssl else aiohttp.TCPConnector(ssl=False)
     headers = {}
     if jwt_token is not None:
         headers["Authorization"] = f"Bearer {jwt_token}"
     async with aiohttp.ClientSession(connector=connector, headers=headers) as 
session:
-        async with session.post(url, json=args.model_dump()) as resp:
+        async with session.post(url, json=args) as resp:
             if resp.status not in (200, 201):
                 text = await resp.text()
                 show_error_and_exit(f"Error message from the 
API:\n{resp.status} {url}\n{text}")
diff --git a/uv.lock b/uv.lock
index 233dc59..db03bb5 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2,7 +2,7 @@ version = 1
 requires-python = ">=3.13"
 
 [options]
-exclude-newer = "2025-07-24T14:24:00Z"
+exclude-newer = "2025-07-24T18:13:00Z"
 
 [[package]]
 name = "aiohappyeyeballs"
@@ -83,7 +83,7 @@ wheels = [
 
 [[package]]
 name = "apache-trusted-releases"
-version = "0.20250724.1424"
+version = "0.20250724.1813"
 source = { editable = "." }
 dependencies = [
     { name = "aiohttp" },


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

Reply via email to