From 6ce83f8a7ae3a74fd189c5cfd4bc7535663d18ff Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Mon, 10 Jul 2023 17:05:53 +0200
Subject: [PATCH] resolve some errors, and fix build-docs.sh

---
 build-docs.sh         | 6 ++++++
 lso/playbook.py       | 6 +++---
 lso/routes/default.py | 7 ++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/build-docs.sh b/build-docs.sh
index 6c37858..7f50cd1 100755
--- a/build-docs.sh
+++ b/build-docs.sh
@@ -1,3 +1,7 @@
+pip install -r requirements.txt
+pip install -e .
+
+export SETTINGS_FILENAME=./config.json.example
 python docs/dump-openapi-spec.py
 
 rm -r ./docs/build/*
@@ -5,3 +9,5 @@ sphinx-apidoc lso lso/app.py -o docs/source -d 2 -f
 vale --config=docs/vale/.vale.ini sync
 vale --config=docs/vale/.vale.ini docs/source/*.rst lso/*.py
 sphinx-build -b html docs/source docs/build
+
+unset SETTINGS_FILENAME
diff --git a/lso/playbook.py b/lso/playbook.py
index 7bbfaeb..3ee51a0 100644
--- a/lso/playbook.py
+++ b/lso/playbook.py
@@ -6,7 +6,7 @@ import uuid
 
 import ansible_runner
 import requests
-from pydantic import BaseModel
+from pydantic import BaseModel, HttpUrl
 
 logger = logging.getLogger(__name__)
 
@@ -84,14 +84,14 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent
     assert request_result.status_code == 204
 
 
-def run_playbook(playbook_path: str, extra_vars: dict, inventory: str, callback: str) -> PlaybookLaunchResponse:
+def run_playbook(playbook_path: str, extra_vars: dict, inventory: str, callback: HttpUrl) -> PlaybookLaunchResponse:
     """Run an Ansible playbook against a specified inventory.
 
     :param str playbook_path: playbook to be executed.
     :param dict extra_vars: Any extra vars needed for the playbook to run.
     :param [str] inventory: The inventory that the playbook is executed
                             against.
-    :param str callback: Callback URL where the playbook should send a status
+    :param :class:`HttpUrl` callback: Callback URL where the playbook should send a status
         update when execution is completed. This is used for
         workflow-orchestrator to continue with the next step in a workflow.
     :return: Result of playbook launch, this could either be successful or
diff --git a/lso/routes/default.py b/lso/routes/default.py
index fa3af42..e79bf02 100644
--- a/lso/routes/default.py
+++ b/lso/routes/default.py
@@ -2,12 +2,13 @@
 
 For now only includes a single endpoint that responds with the current version of the API and LSO.
 """
-import pkg_resources
+from importlib import metadata
+
 from fastapi import APIRouter
 from pydantic import BaseModel, constr
 
 API_VERSION = "0.1"
-VERSION_STRING = constr(regex=r"\d+\.\d+")
+VERSION_STRING = constr(pattern=r"\d+\.\d+")
 
 router = APIRouter()
 
@@ -25,4 +26,4 @@ def version() -> Version:
 
     :return: Version object with both API and `goat-lso` versions numbers.
     """
-    return Version(api=API_VERSION, module=pkg_resources.get_distribution("goat-lso").version)
+    return Version(api=API_VERSION, module=metadata.version("goat-lso"))
-- 
GitLab