From 11b8cec2d3b4f40714be4f9ae183151f2d241eb8 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Feb 17 2021 17:27:21 +0000 Subject: [PATCH 1/2] Add whoami endpoint --- diff --git a/gateway.py b/gateway.py index a81d5a4..843c5cb 100755 --- a/gateway.py +++ b/gateway.py @@ -163,6 +163,10 @@ class Service: "commit_stop": pr, "flags": None, "zuul.yaml": "yes"}) + @app.route("/api/0/-/whoami", methods=['GET', 'POST', 'PUT']) + def whoami() -> Dict: + return flask.jsonify(dict(username="zuul")) + @app.route("/", methods=['GET', 'POST', 'PUT']) def api(subpath: str) -> Dict: token = dict(id=1, description="zuul-token-%d" % time.time(), From 2a1451939b372b17a761d9441623f5a174f7acb7 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Feb 17 2021 17:50:52 +0000 Subject: [PATCH 2/2] Update api model This change adjust the api model to match the latest pagureconnection implementation in Zuul. --- diff --git a/gateway.py b/gateway.py index 843c5cb..fa8aa8d 100755 --- a/gateway.py +++ b/gateway.py @@ -90,7 +90,8 @@ class Service: jobs = {} # type: Dict[str, Dict[str, str]] def sendPayload(topic: str, body: Dict[str, Dict]): - payload = dict(msg_id=str(uuid.uuid4()), topic=topic, msg=body) + payload = dict( + msg_id=str(uuid.uuid4()), topic=topic, msg=body, date_created=0) req = requests.post( Service.zuul, json=payload, headers={ "x-pagure-project": Service.project, @@ -160,7 +161,8 @@ class Service: elif flask.request.form and flask.request.form.get("comment"): Service.jobs[pr]["comment"] = flask.request.form["comment"] return flask.jsonify({"status": "Open", "branch": "master", - "commit_stop": pr, "flags": None, + "commit_stop": pr, "flags": [], + "last_updated": 0, "zuul.yaml": "yes"}) @app.route("/api/0/-/whoami", methods=['GET', 'POST', 'PUT']) @@ -173,6 +175,7 @@ class Service: expired=False) return flask.jsonify(dict(total_branches=1, branches=["master"], + webhook=dict(token=Service.token), connector=dict(api_tokens=[token], hook_token=Service.token)))