in aidial_app_builder_python/__main__.py [0:0]
def main():
dial_base_url = os.environ["DIAL_BASE_URL"]
sources = os.environ["SOURCES"]
profile = os.environ["PROFILE"]
target = Path(os.environ["TARGET_DIR"])
api_key = os.getenv("API_KEY")
jwt = os.getenv("JWT")
print(f"Dial base url: {dial_base_url}")
print(f"Sources: {sources}")
print(f"Profile: {profile}")
print(f"Target folder: {target}")
headers: dict[str, str] = {}
if api_key:
headers["api-key"] = api_key
if jwt:
headers["Authorization"] = f"Bearer {jwt}"
metadata_url = urljoin(dial_base_url, f"v1/metadata/{sources}")
params: dict[str, str] = {"recursive": "true"}
while True:
with requests.get(metadata_url, params, headers=headers) as response:
response.raise_for_status()
result: dict[str, Any] = response.json()
if not result["nodeType"] == "FOLDER":
raise AppValidationException("Sources path must be a folder")
download_files(
dial_base_url,
headers,
unquote(sources),
target,
result.get("items", []),
)
token = result.get("nextToken")
if not token:
break
params["token"] = token
validate(profile, target)